HTML Tutorial || Networking Assignment || Computer Full Forms || Ms-Office Shortcut Keys || Ms-Office Notes || Number System Notes || Internet Assignment
JavaScript Tutorial || CSS Tutorial || Operating System Notes || History of Computer Assignment || Netwoking Notes || Computer Fundamentals Notes

C Program to Check Whether a Number is Even or Odd Using Switch Case ?


Q:- Write a C Program to Check Whether a Number is Even or Odd Using Switch Case ?
      Input
        #include<stdio.h>
        #include<conio.h>
         main()
   {
int num;
clrscr();
printf(“Enter a Number =”);
scanf(“%d”,&num);
switch(num%2)
{
case 0: printf(“%d is Even.”,num);
break;
case 1: printf(“%d is Odd.”);
break;
default : printf(“Invalid Input!!!!!!!!!!!!!!”);
}
getch();
     }


Output

Enter a Number = 2
2 is Even.

Comments