why do you have 2 int main() ?
change
cout << "The Sqaure root of" << x << "equals" << y <<endl;
to
cout <<
"The Sqaure root of
" << x <<
" equals
" << y <<endl; //note the extra spaces.
8 lines. looks good.
edit: The command-prompt will close as soon as the return statement is hit - This means the user won't actually have enough time to read what's on the screen.
You can pause the screen by waiting for user input
Code:
char zz;
cin >> zz; <-- will wait for the user to type something and press {enter}. Technically the variable is never used and the return statement would be executed a moment later.
return 0;
}
2. on Windows(R), use
Code:
system("PAUSE");
return 0;
}
to get the familiar "Press any key to continue..." message. Once any key is pressed the return will get executed and program closes.
^^Your development environment might keep the window open for you / have it's own output window -- but when you share the actual .exe with someone, it will close as soon as the return 0; executes.
And yes plz use [ code ] [ / code] tags to make webpage/code more readable. I think [ b ] (bold) [ / b ] doesn't work inside a [ code ], so sometimes I use [ quote ] [ / quote] because it does allow
bold (if you're drawing attention to a specific line(s) of code).
[ c o d e ] (without spaces)
Code:
int x;
int y;
int z;
[ / c o d e ] (without spaces)
[ q u o t e ] (without spaces)
[ / q u o t e] (without spaces)