+ 1
14.2 Even or Odd
Running into “expected primary expression before %” On line 9. https://sololearn.com/coach/264/?ref=app
6 Antworten
+ 9
You need to use num as an input variable to take any inputs from the compiler.
It's not necessary to declare output variables at the beginning
#include <iostream>
using namespace std;
int main() {
//int odd;
//int even;
int num;
cin>>num;
if (num%2 == 0){
cout<<"even"<<endl; }
else {cout<<"odd"<<endl;}
return 0;
}
+ 3
Jax
To solve any problem you must know the syntax. Just reading cover of the book will not help you to know more about that book. So don't leave the basic concepts and syntax.
It was very basic syntax to get reminder and compare reminder with other value.
+ 1
Thanks, you’re the real
Deal lol.
0
Ive move the paranthesis to (num% ==0) and still get the error
0
Can anyone please help me ,I'm having problem with unlocking the PRO ,can any one carry me along?🙏
- 1
#include <iostream>
using namespace std;
int main() {
int odd;
int even;
int num;
if (num)% == 0{
cout<<"even"<<endl; }
else {cout<<"odd"<<endl;}
return 0;
}