Answer to Question #287053 in C for bob

Question #287053

 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


Enter n: 12
Divisible by 3 and 4


Enter n: 4
Divisible by 4




1
Expert's answer
2022-01-12T11:00:01-0500
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS