0

Wap to chek the given number to even or add

Wap to chek the given number to even or add

3rd Jun 2018, 1:06 PM
Mahendra Kumar
Mahendra Kumar - avatar
3 odpowiedzi
+ 5
What do you mean with "wap"? Anyway, to check if a number is even or odd just use modulo. number%2 will return 0 if the number is even, otherwise it will return 1.
3rd Jun 2018, 1:10 PM
Aaron Eberhardt
Aaron Eberhardt - avatar
+ 3
int num; cin >> num; if (num%2 == 0) { cout << "number is even"; } else { cout << " number is odd"; }
3rd Jun 2018, 1:12 PM
Aaron Eberhardt
Aaron Eberhardt - avatar
+ 1
Please example
3rd Jun 2018, 1:10 PM
Mahendra Kumar
Mahendra Kumar - avatar