C-program to check given number is divisible by a and b

0
55

Given an integer number and two divisors a and b, we have to check whether the number is divisible by a and b in C-Programming.

#include <stdio.h>
int CheckDivision(int num, int a, int b)
{
  if( num%a==0 && num%b==0 )
	return 1;
  else
	return 0;
}

int main()
{
  int number=0,A=0,B=0;
  printf("Enter any integer number : ");
  scanf("%d",&number); 
  printf("Enter first divisor : ");
  scanf("%d",&A); 
  printf("Enter second divisor : ");
  scanf("%d",&B);
  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);
    return 0;
}
Output:
Enter any integer number : 100
Enter first divisor : 10
Enter second divisor : 20
100 is divisible by 10 and 20

LEAVE A REPLY

Please enter your comment!
Please enter your name here