C Program to determine given number is odd or even without using IF

      This C program accomplishes the given task by evaluating the remainder of a given number when divided by 2 directly with in switch case to find odd or even.
So corresponding case gets evaluated depending on the remainder value.

C Program to find whether number is odd or even with out using if

Source Code :

int main()
	int n;
	printf("\n Enter the number:");       
	scanf("%d", &n);                      //Step 1
	switch(n%2)                           //Step 2
		case 0: printf("\n EVEN");        //Step 3
		case 1: printf("\n ODD");         //Step 3
	return 0;


Sample Test cases :

1. Enter the number : 5

2. Enter the number : 4

3. Enter the number : 345


Step 1: Program reads a number from the user using scanf() function.

Step 2: The remainder of a given number when divided by 2 is used in switch case to evaluate the remainder

Step 3: If the remainder is zero then the given number is EVEN otherwise the number is ODD

More Content :Explore More