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?

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 19SA
icon
Related questions
Question

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?

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Concept of memory addresses in pointers
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning