C Programming Print the given no. is odd or even

C programming print the given no.odd and even

 int i;
 printf(“Enter a Numbern”);


 printf(“The number %d is Even”,i);

 printf(“The number %d is Odd”,i);




Enter a Number
The number 5 is Odd

Here we declared an integer ‘i’.

  1. Then we took the input from user using scanf statement.
  2. As we know modulus operator is used to return the reminder of two values as(10%3=1, 12%2=0).
  3. So if you do modulus with 2 then the reminder would be ‘zero’ for Even numbers and ‘1’ for Odd numbers.
  4. If we divide ‘i’ with ‘2’ using mod operator then depending upon condition the respective ‘printf’ will be executed.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

error: Content is protected !!