Header Ads Widget

C++ Program to check whether a number is divisible by 5 and 11 or not. Using the switch statement

 

C++ Program to check whether a number is divisible by 5 and 11 or not. Using the switch statement

Given a number , write a program to check whether it is divisible by both 5 and 11 by using switch case .

Sample input 

 55

Sample output

 Yes

C++ Program to check whether a number is divisible by 5 and 11 or not. Using the switch statement

The objective of the code is check whether a number is divisible by both 5 and 11 or not .

Code(C++):-

#include <iostream>
using namespace std;
int main() {
       int n;
cout<<"Enter the number ";
cin>>n;
int ch=(n%5==0 && n%11==0);
switch(ch)
{
case 1:cout<<"Yes ";
break;
case 0:cout<<"No";
break;
}
}


Output:

Enter the number
55
Yes

Recommended Post :-

HCL Coding Questions:-

Capgemini Coding Questions:-

Companies interview:-

Full C course:-    

Key points:-

Cracking the coding interview:-

 Array and string:-

Tree and graph:-

Hackerearth Problems:-

Hackerrank Problems:-

Data structure:-

 MCQs:-



Post a Comment

0 Comments