Oct 8, 2016 at 12:19pm UTC
#include <iostream>
int main()
{
int a;
int b;
int c;
int d;
cin>>a>>b;
c=a+b ; d=a*b;
if(a%2==0) std::cout<<c<<d;
else cout<<d<<c
}
I got a lot of errors. Can anyone fix it and explain it to me?
Last edited on Oct 8, 2016 at 12:19pm UTC
Oct 8, 2016 at 12:28pm UTC
Write std:: in front of cout and cin and put a ; on the last statement.
Oct 8, 2016 at 1:53pm UTC
Instead of writing std:: all the time, write "using namespace std;" before int main().
Oct 8, 2016 at 2:28pm UTC
also in the second last line you forgot to add a semi-colon
Oct 9, 2016 at 12:04am UTC
I think you have to write
return 0;
at the end of main()
Oct 9, 2016 at 10:19am UTC
I think you have to write
return 0;
at the end of main()
main implicitly returns 0 at the end of the function.
Last edited on Oct 9, 2016 at 10:20am UTC
Oct 13, 2016 at 9:34am UTC
Thank you all.
I fixed it, no compilation errors, but when I open it and type values for a and b a random result appears and the executable stops. What to do?