+ 1
Can you please tell me how can we use conditions in program?
#include <iostream> using namespace std; int main() int n=9; if(n%2==0); { cout<<"Even number"; } else { cout<<"odd number"; return 0; }
4 Answers
+ 7
All is important, what you see in the course. This is your code in right order:
#include <iostream>
using namespace std;
int main() {
int n=9;
if(n%2==0)
{
cout<<"Even number";
}
else
{
cout<<"odd number";
}
return 0;
}
+ 1
Thanks
0
Haram Abbas
your main() is missing opening {
int main(){
and there should not be any
;
at the end of the
if(n%2==0)
0
you are already using if/else condition and btw on line 4 you missed '{}' after main