C Programming Tutorial

Advertisements

Write a program to check whether a number is even or odd in C++



       #include<iostream.h>
       #include<conio.h>
       void main()
       {

              int num;
              clrscr();
              
              cout<<"\nEnter any number : "; 
              cin>>num;

              if(num%2 == 0)              
                     cout<<"\nThe given number is EVEN.";
              else
                     cout<<"\nThe given number is ODD.";

              getch();
       }
       
   Output : 

              Enter any number : 46
              The given number is EVEN.




Advertisement