Write a program that asks the user to enter an integer and determines whether it is divisible by 5 and
6, whether it is divisible by 5 or 6, and whether it is divisible by 5 or 6 but not both.
#include <stdio.h>
#include <stdlib.h>
int main()
{
int num;
printf("Enter the integer number: ");
scanf("%d", &num);
if(num%5 == 0 && num%6 == 0)
{
printf("This number is divisible by BOTH 5 and 6!");
}
else if(num%5 == 0)
{
printf("This number is divisible ONLY by 5 !");
}
else if(num%6 == 0)
{
printf("This number is divisible ONLY by 6 !");
}
else
{
printf("This number is NOT divisible by either 5 or 6!");
}
return 0;
}
Comments
Leave a comment