Blog Moved

This website completely moved to new domain. For latest content, visit www.programmingposts.com

Search This Blog

24 Jul 2012

c program to find the number even or odd

c program to find whether the given number is even or odd..

PROGRAM:
#include <stdio.h>
void main()
{
    int num;

     printf("Enter a number to find Even or Odd: \n");
     scanf("%d",&num);  /* taking input from user*/

    if (num%2==0) /*checking whether the remainder is zero when divided by 2*/
        printf(" The number %d is Even",num);
    else
        printf(" The number %d is Odd",num);

return(0);
}

Sample Output:  (using GNU GCC Compiler with Code Blocks IDE)
Enter a number to find Even or Odd: 5
The number 5 is Odd




No comments:

Post a Comment