#### C Programming

- Print integer
- Add & subtract
- Odd & even
- Multiply & divide
- Check vowels
- Letter grade program
- Leap year program
- Sum of digits
- Prime numbers
- Sum of numbers
- Find factorial
- Fibonacci series
- Fibonacci triangle
- Number triangle
- Alphabet triangle
- Armstrong numbers
- Palindrome numbers
- Swap number
- Reverse number
- Decimal to binary
- Assembly code in C
- Matrix multiplication
- HCF & LCM
- nCr & nPr
- Print pattern
- Floyd’s triangle
- Pascal triangle
- Count digits
- Strong numbers
- Perfect numbers
- Sum of natural number
- Binary to decimal
- Decimal to octal
- Octal to decimal
- Binary to octal
- Octal to binary
- Add using pointer
- Bubble sort
- Insertion sort
- Selection sort
- Quick sort
- Binary search
- Linear search
- Largest element of array
- Smallest element of array
- Reverse Array
- Variable size & limit
- ASCII value of character
- Sum of array elements
- Number of element in array
- Merge two array
- Insert element in array
- Delete element from array
- Add two matrix
- Transpose matrix
- Print string
- Reverse string
- Delete vowels
- Sort string
- Remove spaces
- Swap string
- Random numbers
- Print date & time
- Print IP address
- Shut down computer

## Odd and even in C programming

We will discuss about C programming to check odd and even numbers in this article. We know that even numbers are divisible by two and odd number is not divisible by two. We can implement this idea to determine that a number is odd or even.

Modulus operator (%) is used to determine the reminder. So we can tell that if we get zero as reminder when we divide a number by 2 then the number will be even. Otherwise it will be odd. So, lets implement this idea to make an odd and even C program.

## Program to determine odd and even

```
// c program for odd and even
#include <stdio.h>
int main(){
int num;
printf("Enter an integer to check : ");
scanf("%d", &num);
if (num % 2 == 0){
printf("%d is even.\n", num);
}else{
printf("%d is odd.\n", num);
}
return 0;
}
```

### Output of this odd even program

## Odd and even program using conditional operator

Conditional operator is a special type of operator and if you don’t know about various operators then it is time to see our another article about operators in C which will let you know all about operators.

```
// odd and even using condition
#include <stdio.h>
int main(){
int number;
printf("Input an integer here : ");
scanf("%d", &number);
number % 2 == 0? printf("Even\n"):printf("Odd\n"); // conditional operator
return 0;
}
```

### Output:

## Finding odd or even using bitwise operator

If you don’t know about bitwise operator then we will highly recommended you to visit our bitwise operator article in C then try to understand the code bellow.

```
// odd and even by bitwise operators
#include <stdio.h>
int main(){
int num;
printf("Input an integer to check : ");
scanf("%d", &num);
if (num & 1 == 1){
printf("The number is odd.\n");
}else{
printf("The number is even.\n");
}
return 0;
}
```

### See the output

## Odd or even program in other way in C

If we divide an even number by 2 and again multiply the result by 2 then we will get the original number.

Suppose,

8 / 2 = 4 and 4 * 2 = 8

Now, 8 ==8

But in case of odd number, when we divide it by 2 will get a fraction number and as we have taken the integer data type, the fraction part will be ignored. Then we will multiply the result by 2 which will give the result not equal to original number.

Suppose,

7 / 2 = 3 and 3 * 2 = 6

Now 7 != 6

```
#include <stdio.h>
int main(){
int num;
printf("Enter an integer to check : ");
scanf("%d", &num);
if ((num / 2) * 2 == num){
printf("Even\n");
}else{
printf("Odd\n");
}
return 0;
}
```

### See the output of this odd even program

```
Enter an integer to check : 15
Odd
Process returned 0 (0x0) execution time : 5.706 s
Press any key to continue.
```

**Previous page**: **Add and subtract program**

**Next page**: **Multiply and divide program**