by CodeChum Admin
Do you still know what being divisible by a certain number means? In case you forgot, being divisible means that the number is capable of being divided by another number without a remainder. With this knowledge, you can surely solve this problem!
Instructions:
Input
1. An integer
Output
The first line will contain a message prompt to input the integer.
The second line contains the appropriate message.
Enter n: 6
Divisible by 3
Enter n: 12
Divisible by 3 and 4
Enter n: 4
Divisible by 4
#include <stdio.h>
int main() {
int n;
printf("Enter n: ");
scanf("%d", &n);
if (n%3 == 0 && n%4 != 0) {
printf("Divisible by 3\n");
}
if (n%4 == 0 && n%3 != 0) {
printf("Divisible by 4\n");
}
if (n%3 == 0 && n%4 == 0) {
printf("Divisible by 3 and 4\n");
}
return 0;
}
Comments
Leave a comment