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

Popular posts from this blog

To convert hexadecimal to decimal numbers.

To convert hexadecimal to decimal numbers.