Thursday, 16 August 2012

Find odd or even using conditional operator

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

No comments:

Post a Comment