C Program Check whether a Number is Divisible by 5 and 7

Write a C program to check whether a number is divisible by 5 and 7.

C Program:

/* Aim: To Check Whether the number is divisible by 5 and 7 */

#include<stdio.h>

int main()
{
	int a;
 
	printf("\n Enter Your number:");
	scanf("%d",&a);

	if (a%5==0 && a%7==0)
	{
	printf("\n %d is divisible by 5 and 7 \n \n",a);
	}
	else
	{
	printf("\n %d is not divisible by 5 and 7 \n \n",a);
	}
	return 0;
}

Output:

[root@localhost ~]# gcc -o e2a4 e2a4.c
[root@localhost ~]# ./e2a4

 Enter Your number:35

 35 is divisible by 5 and 7 
 
[root@localhost ~]# ./e2a4

 Enter Your number:45

 45 is not divisible by 5 and 7

Comments