write a program to check whether a number is divisible by 5 and 11 or not.using the switch statement
#include<iostream>
using namespace std;
int main()
{
int value;
do
{
cout << "\nPlease, enter a value(0 - break): ";
cin >> value;
if (value == 0)break;
if ((value % 11 == 0) && (value % 5 == 0))
{
cout << value << " is divisible by 5 and 11";
}
else
{
if (value % 5 == 0)
{
cout << value << " is only divisible by 5";
}
else if (value % 11 == 0)
{
cout << value << " is only divisible by 11";
}
else
{
cout << value << " is not divisible by 5 and 11";
}
}
} while (true);
}
Comments
Leave a comment