Situatie
To Check if a given number is even or odd we simply divide the given number by 2, if the remainder is 0 then it is even otherwise odd.
Backup
#include <iostream>
using namespace std;
int main() {
int a ;
cin>>a;
if(a%2 == 0) // if remainder is zero then even number
cout<<”even”;
else
cout<<”odd”;
return 0;
}
Input: 8
Output: even
Leave A Comment?