write a program to check number is even or odd
We know that even number is that number that has remainder 0 when we get the remainder of the particular number. If remainder is not 0 then this number is odd number. The code for this program is as follows:
cout<<"Enter any number : ";
if(no%2 == 0)
In the above program we have used the following header files as follows:
#include<iostream.h> used for input/output of data
#include<conio.h> provides several functions like clrscr(), getch() etc.
After that in main() function we have declared a variable no. after that we have used clrscr(); function to clear the scree when program will run. It will clear the previous output from any program. Now we have used the cout function that shows message “Enter any number :”; and when we enter any number then this number is read by cin function and assign to no variable. After that we have used if condition, here we check that if no%2 is equal to 0 then if blocl will be executed otherwise else block.
The output is as follows: