Here are my C++ program instructions Write a program that prompts the user to enter a positive integer and then uses this criterion to determine whether the number is divisible by 11. Example output (Program output should be in a similar format): 121 is divisible by 11 12 is not divisible by 11 Here's what I have so far: //input the neccessary #include-header files.#include <iostream> //input the neccessary namespace standards.using namespace std; //define the main functionint main(){//declare variablesint numb;int divi;int sum; //Prompt the user to input a number value to be tested.cout <<"Please enter a positive interger: ";cin >> numb;cout << endl; divi = numb;sum = 0; do{sum = sum + numb % 10;numb = numb / 10;sum = sum - numb % 10;numb = numb / 10;}while (numb > 0);cout <<"The sum of the intergers is: " << sum << endl;if (sum % 11 == 0){cout << divi <<" is divisible by 11" << endl;}else{cout << divi <<" is not divisible by 11" << endl;} return 0;} What I have to do is program a loop function to make the program work. However, I have no idea how to get that far. Everytime I look at it, I only see and infinite loop. Can someone help me?
Here are my C++ program instructions
Write a program that prompts the user to
enter a positive integer and then uses this
criterion to determine whether the number
is divisible by 11.
Example output (Program output should be
in a similar format):
121 is divisible by 11
12 is not divisible by 11
Here's what I have so far:
//input the neccessary #include-header files.
#include <iostream>
//input the neccessary namespace standards.
using namespace std;
//define the main function
int main()
{
//declare variables
int numb;
int divi;
int sum;
//Prompt the user to input a number value to be tested.
cout <<"Please enter a positive interger: ";
cin >> numb;
cout << endl;
divi = numb;
sum = 0;
do
{
sum = sum + numb % 10;
numb = numb / 10;
sum = sum - numb % 10;
numb = numb / 10;
}
while (numb > 0);
cout <<"The sum of the intergers is: " << sum << endl;
if (sum % 11 == 0)
{
cout << divi <<" is divisible by 11" << endl;
}
else
{
cout << divi <<" is not divisible by 11" << endl;
}
return 0;
}
What I have to do is program a loop function to make the program work. However, I have no idea how to get that far. Everytime I look at it, I only see and infinite loop. Can someone help me?
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images