Answer to Question #181329 in C for Cosmas Nyathi

Question #181329

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. 


1
Expert's answer
2021-04-14T05:45:22-0400
#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;
}

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