0
Whats wrong with this? Im newbie, and compiler says there is no if before else. Thanks for any advice.
#include <iostream> using namespace std; int main() { int siblings, popsicles; //take input cin>>siblings ; cin>>popsicles ; if((popsicles%siblings) == 0);{ cout <<"give away"; else{ cout <<"eat them yourself." } } return 0; }
6 Respuestas
+ 6
The semicolon after the condition of the if statement does not belong there.
Furthermore, the else statement is nested inside the if statement, where it should follow after it, i.e.
if ( ... )
{
...
}
else
{
...
}
You are also missing a semicolon after the second output, and I would recommend checking the printed statements match the requirements of the code coach.
+ 5
Remove ";" behind the if statement.
And I think there is a ";" missing in 2nd cout line
+ 1
Thanks a lot, it worked. I feel kinda retarded considering its popsicles problem xd.
0
Slimmy Jimmy actually this kind of problem always happen to programmers..even the expert one xD
0
Ok im newbie so im not surprised. I was like in cpp u have to put more braces and semilcon as much as you can, after statements or comments. I probably should learn the basics an then do the problems. xd
0
Please remove the ; after if statement .. then it will work