Answer to Question #300205 in C++ for saim

Question #300205

write a program to check whether a number is divisible by 5 and 11 or not.using the switch statement

1
Expert's answer
2022-02-20T14:40:56-0500
#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);
}

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