To printf whether given number is even or odd:


program:

 #include<stdio.h>

main()

{

int i;

printf("Enter the number to check whether given number is even or odd\n");

scanf("%d",&i);

if(i%2==0)

{

printf("The given number is %d is even",i);

}

else

{

printf("The given number is %d is odd",i);

}

printf("\n");

}

Output:

Enter the number to check whether given number is even or odd

5

The given number is  5 odd

Explanation:

1.here we declared an integer "i"

2.then we took the input from user scanf() statement.

3.as we know modulus operator is used to return the reminder of two values as(10%3=1,12%2=0)

4.so if you do modulus with with 2 then the reminder would be zero for even numbersand 1 for odd numbers

5.if we divide i  with 2 using mod operator then depending upon condition the respective printf() will

be executed