Write a c program to check the number is even or odd using switch case - CodeTextPro | Free Web Tutorial

Codetextpro Provides free Web tutorial, HTML, CSS, C, C++, Java, JavaScript, PHP, MySql, Python, Program, Programming Notes, Programming Questions and more.

Programming

Saturday, January 5, 2019

Write a c program to check the number is even or odd using switch case

Even or Odd Using Switch Case

In this program, you will learn how to check the number is even or odd in c using switch case(input enter by the user). 

Check the number is even or odd using switch case:


#include<stdio.h>

#include<conio.h>
main()
{
int x,y;
printf("Enter the value to check even or odd:\n");
scanf("%d",&x);
y=x%2==0?1:0;
switch(y)
{
case 1:
printf("Number is Even");
break;
case 0:
printf("Number is Odd");
break;
default:
printf("thank you");
}
getch();
}


Output:



No comments:

Post a Comment