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 <iostream>
#include <conio.h>
using namespace std;
int main()
{
int n;
cout<<"Enter a number ";
cin>>n;
switch(n%7)
{
case 0:
cout<<"Multiple of 7";
break;
default:
cout<<"Not multiple of 7";
}
return 0;
}
Output
Enter a number 49 Multiple of 7