Sunday, July 30, 2017

Write a program that accepts a number from a user and tells whether the number is even or odd.

#include <iostream>
using namespace std;

int main(){

int x =0;

cout<<"Enter an integer number : ";
cin >>x;
cout <<endl;

if(x%2==0){
  cout <<x<<" is an even number."<<endl;
}
else{
  cout <<x<<" is an odd number."<<endl;
}

return 0;
}
Share: