# C Program to Check Whether a Number is Even or Odd

C Program to Check Whether a Number is Even or Odd

This is the example of c-programming. You can edit and compile code in your own way on clicking button. If you have better solution or you found any error on code, then give us suggestion.

## Code Explanation :

To understand this example, you should have the knowledge of the following C programming topics:

The number divisible by 2 exactly is known as even number. For instance: 0, 8, -24

The number is not divisible by 2 exactly is known as odd number. For instance: 1, 7, -11, 15

In the program, the integer entered by the user is stored in the variable num.

whether or not numbers are perfectly divisible by 2 is checked using the `%` operator modulus.

If the number (given by user) is perfectly divisible by 2 then test expression evaluates to `1` (true) that means the number is even.

And if test expression evaluates to `0` (false) that means the number is even.

## Program to Check Odd or Even Using the Ternary Operator

```#include &gt;stdio.h&lt;
int main() {
int num;
printf("Enter an integer: n");
scanf("%d", &amp;num);

(num % 2 == 0) ? printf("%d is even.", num) : printf("%d is odd.", num);
return 0;
}```

The output of this program is also same as above program.

We have used ternary operator `?:` instead of `if...else`.

## Algorithm

```Step 1: Start

Step 3: If Number % 2 == 0 THEN

Print Number is an Even Number.
Else
Print Number is an Odd Number.

Step 4: Exit```

## Flowchart

Our example mainly covers following topics in any programing

• Basic Programs
• Number Programs
• Array Programs
• Matrix Programs
• Pattern Programs
• String Programs
• Tree Programs

Here we share programs on various topics such as array strings, series area & volume of geometric figures, mathematical calculation algorithms for sorting & searching and much more.Our goal is to provide you with the perfect solution to all the programming problems you may have encountered either during interviews or in class assignments. If you don’t find what you are looking for then please drop a line in the comment section of example page or you can request from account page so that we can get it added to the below collection of programs. Happy Learning!!

If you are confident with the above programs and are able to successfully understand and run them without any problems then it is time for you to take a step further and learn comprehensive programming principles using examples and flow diagrams. Here is the link: Programming tutorial lists .

If you find any code error or grammetical error then you can suggest for example improvement on clicking below button.

## // SEARCH

What are you searching for....?