Write a C program to check whether a number is divisible by 5 and 11 or not using if else. How to check divisibility of any number in C programming. C program to enter any number and check whether it is divisible by 5 and 11 or not. Logic to check divisibility of a number in C program.

**Example**

**Input**

Input number: 55

**Output**

Number is divisible by 5 and 11

## Required knowledge

## Logic to check divisibility of a number

Checking divisibility of a number means that the number is exactly divisible by some other number leaving no remainder. To check divisibility of a number, we need to check if remainder is 0 or not. If it is zero then only the number is exactly divisible otherwise not.

C programming supports an operator known as modulo % operator. Modulo operator returns remainder.

For example:

5 % 2 = 1 (Since 5/2 leaves 1 as remainder)

2 % 5 = 2 (Since 5 goes in 0 times leaving remainder 2)

8 % 2 = 0 (Since 8/2 leaves 0 as remainder)

Below is the step by step descriptive logic to check whether a number is divisible by 5 and 11 or not.

- Input a number from user. Store it in some variable say num.
- If num % 5 == 0 and num % 11 == 0. Then the number is exactly divisible by 5 and 11.

Let us implement the logic.

## Program to check divisibility

```
/**
* C program to check divisibility of any number
*/
#include <stdio.h>
int main()
{
int num;
/* Input number from user */
printf("Enter any number: ");
scanf("%d", &num);
if((num % 5 == 0) && (num % 11 == 0))
{
printf("Number is divisible by 5 and 11");
}
else
{
printf("Number is not divisible by 5 and 11");
}
return 0;
}
```

Output

Enter any number: 55 Number is divisible by 5 and 11

Happy coding 😉

### Recommended posts

- If else programming exercises index.
- C program to find maximum between three numbers.
- C program to check whether a number is positive, negative or zero.
- C program to check leap year.
- C program to check even or odd.
- C program to find whether a triangle is valid or not if angles of triangle are given.
- C program to enter any character and check whether it is alphabet, digit or special character.

<pre><code> ----Your Source Code---- </code></pre>