Computer Science, asked by rohansm226, 11 months ago

Divisible by 7 and 3 write a program to find whether a given number is divisible by both 7 and 3. Input format: input consists of a single integer. Output format: output consists of a single line. Refer sample output for the format. Sample input 1: 21 sample output 1 : 21 is divisible by both 7 and 3 sample input 2: 18 sample output 2: 18 is not divisible by both 7 and 3

Answers

Answered by ajayvermajnv04
3

Answer:your answer in following

Explanation:

DIVISIBLE BY 7 AND 3

Write a program to find whether a given number is divisible by both 7 and 3.

Input Format:  

Input consists of a single integer.

Output Format:

Output consists of a single line. Refer sample output for the format.

Sample Input 1:  

21

Sample Output 1 :  

21 is divisible by both 7 and 3

Sample Input 2:  

18

Sample Output 2:  

18 is not divisible by both 7 and 3

Code:

 #include<stdio.h>

int main(){

 int a;

 scanf("%d",&a);

 if((a%3==0)&&(a%7==0))

   printf("%d is divisible by both 7 and 3",a);

 else

   printf("%d is not divisible by both 7 and 3",a);

 

 return 0;

}

Similar questions