C program to find even or odd using conditional operator

#include<stdio.h>

int main()

{

    int a;

    printf("Enter the number\n ");

    scanf("%d",&a);

    (a%2==0)?printf("Entered number is even"):printf("Entered number is odd");

}


Output:
Enter the number
5
Entered number is odd

No comments:

Post a Comment