To print whether the number entered is even or odd, using conditional operator
#include
#include
void main()
{
int
num;
char
c;
clrscr();
do
{
printf("Enter any
number:\t");
scanf("%d",&num);
num%2==0
? printf("\nNumber is even\n") : printf("\nNumber is
odd\n");
printf("\nPress
Y if you want to continue:\t");
c=getche();
printf("\n\n");
}
while(c=='y'||c=='Y');
getch();
}
Comments
Post a Comment