Challenge 2 Help | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Challenge 2 Help

int a; cin>>a; if(a _ 2==0) cout <<"The number is even"; else cout <<"The number is odd"; What to put here?

8th Sep 2016, 7:29 AM
Haziq Khairi
Haziq Khairi - avatar
1 Answer
+ 1
% gives you the remainder of an euclidian division. 42%9 is 6 (since 42 is 9*4+6) a%b is 0 if a is a multiple of b a%1 is always 0 a%2 is 0 if a is even and 1 if a is odd a%10 gives you the last digit of a a%100 gives you the last two digits of a etc.
8th Sep 2016, 7:37 AM
Zen
Zen - avatar