0
What is wrong with this c++ code? Please help
#include <iostream> using namespace std; int main() { int a, b; cout << "a is" << endl; cin >> a; cout << "b is" << endl; cin >> b; if (a > b) { cout << "greatest is " << a << endl; } if (b > a) { cout << "greatest is " << b << endl; }
5 Respuestas
+ 2
It would be much better if you would post a link to your code then we wouldnt have to copy this.
+ 1
「HAPPY TO HELP」 a return 0; is not needed, c++ will return 0 by default in main if no return statement is given
+ 1
Max yes, and it's considered a mistake in C++ standard even said by the creator of the language. So some compilers will probably see it as mistake. Yet in the code there is no closing bracket for main function that will always yield an error, no matter what compiler we're on ;)
+ 1
Jakub Stasiak i never said that there isn‘t a bracket missing. if the compiler doesn‘t compile a main function without a return statement it‘s not standard compliant, no matter what Bjarne Stroustrup thinks about it
0
return 0 ;
and please use else clause