# C program to check given number is divisible by A and B

In this C program, we will **read an integer number and check whether given integer number is divisible by A and B**. Here, A and B are the divisors given by the user.

Submitted by **IncludeHelp**, on March 27, 2018

Given an integer number *number* and two divisors *A* and *B*, we have to check whether number is divisible by A and B in C.

**Example:**

Input:
number = 100
A = 10, B = 20
Output:
100 is divisible by 10 and 20
Input:
number = 90
A = 10, B = 20
Output:
90 is not divisible by 10 and 20

To check whether a given number is divisible by two divisors (A and B) or not, we are creating a function named CheckDivision() which will return 1, if number is divisible by both divisors else it will return 0.

**Function declaration:**

int CheckDivision(int num, int a , int b)

**Here,**

- int is the return type
- CheckDivision is the function name
- int num is the number to divide
- int a , int b are the divisors

**Statements with function calling:**

if(CheckDivision(number,A,B))
printf("%d is divisible by %d and %d\n",number,A,B);
else
printf("%d is not divisible by %d and %d\n",number,A,B);

Statement printf("%d is divisible by %d and %d\n",number,A,B); will be executed if function will return 1 else printf("%d is not divisible by %d and %d\n",number,A,B); will be executed.

## Program to check number is divisible by A and B in C

need an explanation for this answer? contact us directly to get an explanation for this answerOutput