Divisibility Check Program
The following C program checks whether a given number is divisible by both 5 and 7.
#include <stdio.h>
int main() {
int number;
printf("Enter a number: ");
scanf("%d", &number);
if (number % 5 == 0 && number % 7 == 0) {
printf("%d is divisible by both 5 and 7.\n", number);
} else {
printf("%d is not divisible by both 5 and 7.\n", number);
}
return 0;
}
Test the Program
Explanation
- The program begins by including the standard input/output library
stdio.h. - In the
main()function, an integer variablenumberis declared to store the user input. - The program prompts the user to enter a number using
printf(). - The user's input is read using
scanf()and stored in thenumbervariable. - An
ifstatement checks if the entered number is divisible by both 5 and 7 using the modulo operator%. - If the remainder of the division by 5 is 0 and the remainder of the division by 7 is also 0, the program prints a message stating that the number is divisible by both 5 and 7.
- If the conditions in the
ifstatement are not met, the program prints a message stating that the number is not divisible by both 5 and 7. - The program ends with the
return 0;statement, indicating successful execution.

If you have any doubts, Please let me know