Header Ads Widget

C program to check whether a number is divisible by 5 and 11 or not

 C program to check whether a number is divisible by 5 and 11 or not

Given a number , write a program to check whether it is divisible by 5 and 11 or not .

Sample input

55 

Sample output

55 is divisible by both 5 and 11

C program to check whether a number is divisible by 5 and 11 or not

The objective of the code is to find whether number is divisible by 5 and 11 or not .

Code(C):-

#include<stdio.h>
int main()
{
int a;
scanf("%d",&a);
if(a%5==0 && a%11==0)
printf("%d is divisible by both 5 and 11",a);
else if(a%5==0)
printf("%d is divisible by 5 ",a);
else if(a%11==0)
printf("%d is divisible by 11",a);
else
printf("%d is not divisible by both 5 and 11",a);

return 0;
}

Output:-

55
55 is divisible by both 5 and 11

Recommended Post :-

HCL Coding Questions:-

Capgemini Coding Questions:-

Companies interview:-

Full C course:-    

Key points:-

Cracking the coding interview:-

 Array and string:-

Tree and graph:-

Hackerearth Problems:-

Hackerrank Problems:-

Data structure:-

 MCQs:-