# even odd program in c

In this post, we will see about even odd program in c.

Even numbers are those numbers which are divisible by 2 and numbers which are not divisible by 2 are called odd numbers.

There are many ways to check if number is even or odd in C.

Table of Contents

## Using modulus operator

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
#include<stdio.h> int main() { int num; printf("Enter an number: "); scanf("%d",&num); // Modulus (%) returns remainder if ( num%2 == 0 ) printf("%d is an even number", num); else printf("%d is an odd number", num); return 0; } |

**Output:**

Enter an number: 19

19 is an odd number

19 is an odd number

## Using bitwise operator

You can also use bitwise operator to find if number is even or odd. If number is odd, then its least significant digit will always be 1 and when you perform number&1, it will always result in 1.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
#include<stdio.h> int main() { int num; printf("Enter an number: "); scanf("%d",&num); // Use and(&) operator if ( num & 1 == 1 ) printf("%d is an odd number", num); else printf("%d is an even number", num); return 0; } |

**Output:**

Enter an number: 28

28 is an even number

28 is an even number

## Using conditional operator

You can also use conditional operator to find if number is even or odd.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
#include<stdio.h> int main() { int num; printf("Enter an number: "); scanf("%d",&num); // Use ternary operator num%2==0?printf("%d is an even number", num): printf("%d is an odd number", num); return 0; } |

**Output:**

Enter an number: 49

49 is an odd number

49 is an odd number

## Without using modulus and bitwise operator

If you are not allowed to use modulus and bitwise operator, you can use below method to find even and odd number in c.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
#include<stdio.h> int main() { int num; num=49; if ((num/2)*2 == num) printf("%d is an even number", num); else printf("%d is an odd number", num); return 0; } |

**Output:**

Enter an number: 52

52 is an even number

52 is an even number

That’s all about even odd program in c.