Question #326339

1. Visibly Divisible

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:

  1. Input one integer.
  2. Make a conditional statement that contains the following conditions:
  3. If the integer is only divisible by 3, print "Divisible by 3"
  4. If the integer is only divisible by 4, print "Divisible by 4"
  5. If the integer is divisible by both 3 and 4, print "Divisible by 3 and 4"

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

Expert's answer

#include <stdio.h>


int main() {
    int n;


    printf("Enter n: ");
    scanf("%d", &n);


    if (n%3 == 0 && n%4 != 0)
        printf("Divisible by 3");
    if (n%3 != 0 && n%4 == 0)
        printf("Divisible by 4");
    if (n%3 == 0 && n%4 == 0)
        printf("Divisible by 3 and 4");
    
    return 0;
}
LATEST TUTORIALS
APPROVED BY CLIENTS