C Programs | IT Developer
IT Developer

C Programs



Share with a Friend

Decision Making Programs in C

Check whether a number is divisible by 5 and 11

Introduction

Divisibility means a number can be divided by another number without leaving a remainder.

  • If number % 5 == 0, it is divisible by 5.
  • If number % 11 == 0, it is divisible by 11.

In this program, we check whether the given number is divisible by both 5 and 11.

 

C Program: Check whether a number is divisible by 5 and 11

C

#include <stdio.h>

 

int main() {

    int num;

 

    // Input number

    printf("Enter a number: ");

    scanf("%d", &num);

 

    // Check divisibility

    if (num % 5 == 0 && num % 11 == 0) {

        printf("%d is divisible by both 5 and 11.\n", num);

    }

    else {

        printf("%d is not divisible by both 5 and 11.\n", num);

    }

 

    return 0;

}

Output

 
OUTPUT 1 :
Enter a number: 55
55 is divisible by both 5 and 11.

OUTPUT 2 :
Enter a number: 25
25 is not divisible by both 5 and 11.

OUTPUT 3 :
Enter a number: 110
110 is divisible by both 5 and 11.

Explanation

  1. User enters an integer.
  2. The program uses the modulus operator % to check if the number gives remainder 0 when divided by 5 and
  3. If both conditions are true → divisible by 5 and 11.
  4. Otherwise → not divisible by both.