representing cout as a function

Please how do i represent this as a function that i can get to call at any time for cout values???


double w;
double y = 0;
if ( y == 1 )
{
cout << "\nThe area of square with side " << y << " foot is " << w << " squarefoot\n" ;
}
else
{
cout << "\nThe area of square with side " << << " feet is " << w << " squarefeet\n" ;
}
cout << "\nTo continue, press 1 else press any other key to exit\n";
cout << "Choice:\t";
cin >> q;
if (q==1)
{
break;
}
else
{
return 0;
}



I have no idea what you're asking.
add void myfunction() { before that code
and } after it
;^)

[edit] actually int myfunction() { since you have return 0
Last edited on
i am new to C++ and doing an assignment, i am working on calculations for different shapes and need to have all what i have in my post up there for each shape i am working on and it would involve too much codes if i put the whole of that up there under each shape. so i need to represent it as a function before int main(), so i can call for it anytime i need it
@Bazzy, i cannot seem to break through the problem. i dont think i could use int bcos its not integer that is being returned. its those things on the cout>>>......sorry if i am getting u wrong, could u pls put me through
Topic archived. No new replies allowed.