C Program To Print Number Is Even or Odd Without Using "if-else" Statement Using "Switch-Case"

Program to Print number is even or odd without using if-else statement using switch case:


#include<stdio.h>
int main()
{
int no;
printf("enter the no\n");
scanf("%d",&no);
/*If number is completely divisible by 2 means (no%2=0) is true then inside the case 0: print number is even, otherwise inside the case 1: print number is odd.*/
switch(no%2)
{
case 0: printf("no is even");
break;
case 1: printf("no is odd");
}
    return 0;
}



Above Program show's the following output:


C Program To Print Number Is Even or Odd Without Using  "if-else" Statement Using "Switch-Case"


No comments:

Post a Comment

If you have any doubts, please discuss here...👇