Sponsor

C Programming Tutorial #4, C program to check odd or even

C program to check odd or even: We will determine whether a number is odd or even by using different methods all are provided with a code in c language. As you have study in mathematics that in decimal number system even numbers are divisible by 2 while odd are not so we may use modulus operator(%) which returns remainder, For example 4%3 gives 1 ( remainder when four is divided by three). Even numbers are of the form 2*p and odd are of the form (2*p+1) where p is is an integer.

C program to check odd or even using modulus operator

#include <stdio.h>
 
int main()
{
   int n;
 
   printf("Enter an integer\n");
   scanf("%d", &n);
 
   if (n%2 == 0)
      printf("Even\n");
   else
      printf("Odd\n");
 
   return 0;
}


Share on Google Plus

About Unknown

We bring you the latest breaking news that are happening around the world. For daily news, celebrity gossips, scoops, scandals, sports news, crime news and many more, don't forget us to visit ... www.satyaaawaz.com.
    Blogger Comment
    Facebook Comment

0 comments :

Post a Comment