+ 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; }

27th Oct 2023, 4:09 PM
Haram Abbas
Haram Abbas - avatar
4 Respostas
+ 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; }
27th Oct 2023, 5:14 PM
JaScript
JaScript - avatar
+ 1
Thanks
28th Oct 2023, 10:55 AM
Haram Abbas
Haram Abbas - avatar
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)
28th Oct 2023, 2:17 AM
Bob_Li
Bob_Li - avatar
0
you are already using if/else condition and btw on line 4 you missed '{}' after main
28th Oct 2023, 7:51 AM
Alhaaz[Inactive]
Alhaaz[Inactive] - avatar