/* C Program to check whether the entered number is even
or odd using conditional (ternary) operators
*/
#include<stdio.h>
#include<conio.h>
void main()
{
int n;
clrscr();
printf("Enter a number:");
scanf("%d",&n);
(n%2==0)?printf("Even Number"):printf("Odd Number"); /* Ternary/conditional operator to check even or odd */
getch();
}
or odd using conditional (ternary) operators
*/
#include<stdio.h>
#include<conio.h>
void main()
{
int n;
clrscr();
printf("Enter a number:");
scanf("%d",&n);
(n%2==0)?printf("Even Number"):printf("Odd Number"); /* Ternary/conditional operator to check even or odd */
getch();
}
No comments:
Post a Comment