Computer Science, asked by UniquePrincess1234, 10 months ago

Write a program to test whether a given number is divisible by another given number ​

Answers

Answered by sajal582033
2

Answer:

mark answer as brainlist dear❤❤

hv a nice day dear ❤❤✌✌✌

Explanation:

The program output is also shown below.

public class Check_Divisiblity.

int n;

Scanner s = new Scanner(System.

System. out. print("Enter any number:");

n = s. nextInt();

if(n % 5 == 0)

System. out. println(n+" is divisible by 5");

System. out. println(n+" is not divisible by 5");

Answered by akashhari52
3

Explanation:

/**

C program to check given number

is divisible by A and B

Here, A and B are integers

*/

#include <stdio.h>

//function will return 1 if given number is

//divisible by both numbers a and b

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

{

//we have to check whether num is

//divisible by a and b

if( num%a==0 && num%b==0 )

return 1;

else

return 0;

}

// main function

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;

}

Similar questions