Odd or Even Program in C

Odd or even program in c. The software takes an integer and determines if it is odd or even. Here’s the source code for a C program that determines whether a number is odd or even.

#include <stdio.h>
void main()
{
int value, rem;
printf("Enter an int ");
scanf("%d", &value);
rem = value % 2;
if (rem == 0)
printf("%d is an even int\n", value);
else
printf("%d is an odd int\n", value);
}

 

Output:

Enter an int 45
45 is an odd int

Odd or Even Number in C

To check an integer, the user must first enter it into the variable value. Divide the variable value by 2 to get the remainder of the integer, which is stored in the variable remainder. To see if the value of the variable residual is equal to zero, use the if, else expression. If it equals zero, print “the integer is an even integer” as the output.

Remainder in C Program

The residual is the quantity “left over” after executing a calculation in mathematics. The residual is the integer that remains after dividing one integer by another to obtain an integer quotient in arithmetic. Remainder concept is very important to execute odd or even program in c

Even Number in C

A whole number that may be split into two equal whole numbers by two. Even numbers are zero, two, four, six, and eight.

Odd Number in C

Whole numbers that cannot be split perfectly into pairs are known as odd numbers. Odd numbers have a residual of one when divided by two.