Dremendo Tag Line

Input number check multiple of 7 or not using switch case in C

switch case - Question 3

In this question, we will see how to input an integer and check whether it is a multiple of 7 or not in C programming using the switch case statement. To know more about switch case statement click on the switch case statement lesson.

Q3) Write a program in C to input an integer and check whether it is a multiple of 7 or not using the switch case statement.

Program

#include <stdio.h>
#include <conio.h>

int main()
{
    int n;
    printf("Enter a number ");
    scanf("%d",&n);
    switch(n%7)
    {
        case 0:
            printf("Multiple of 7");
            break;

        default:
            printf("Not multiple of 7");
    }
    return 0;
}

Output

Enter a number 49
Multiple of 7
video-poster