### Program to Check Number is Even or Odd

Here we are going to write program to check enter number is even or odd . We have to know about operator used in C which is most important for applying condition in the program . On the previous blog I told you about operator used in C so please read from there . For writing program to check number is even or odd. As we know that even number are those number which are exactly divisible by 2 and odd number are those which are not divisible by 2. Now we are going to write program.

/*program to check no.is even or odd*/

#include <stdio.h>

void main()

{

int a;

clrscr ();

printf ("/n Enter a number:");

scanf ("%d", & a);

if ( a%2==0)

printf ("/n a is even number:");

else

printf ("/n a is odd number :");

getch();

}

From written program you seen that first of all we have to enter a number from the user and then we have used condition for checking. A even number is divisible by 2 then it must gives 0 as remainder then print number is even otherwise it will we odd number. Please comment for any issue in this program for spreading information.

/*program to check no.is even or odd*/

#include <stdio.h>

void main()

{

int a;

clrscr ();

printf ("/n Enter a number:");

scanf ("%d", & a);

if ( a%2==0)

printf ("/n a is even number:");

else

printf ("/n a is odd number :");

getch();

}

From written program you seen that first of all we have to enter a number from the user and then we have used condition for checking. A even number is divisible by 2 then it must gives 0 as remainder then print number is even otherwise it will we odd number. Please comment for any issue in this program for spreading information.

### Algorithm to find out even or odd :

Now we are going to write algorithm for this program as we discuss earlier algorithm is step by step representation of program. Algorithm is generally out in capital letter and always start with START and end with STOP. In C programming

language it is very important to write algorithm.

ALGORITHM : CHECK NUMBER IS EVEN OR ODD.

This is a program to input a number and check input number is even or odd.

STEP 1. START.

STEP 2. INPUT A NUMBER.

STEP 3. { CHECK NUMBER IS EVEN OR ODD }

1. IF A IS DIVISIBLE BY 2.

2. PRINT " A IS EVEN ".

3. OTHERWISE.

4, PRINT " A IS ODD".

{ END OF LOOP 3 }

STEP 4. STOP.

## No comments:

## Post a Comment