Answer to Question #317874 in C++ for Wushu

Question #317874

Using a do...while() loop, continuously scan for random integers that will be inputted by the user and print out its square, separated in each line.


Once the inputted value is 0, it will still print out its square value but should then terminate the loop afterwards. Use this concept in making your loop condition.

1
Expert's answer
2022-03-25T07:38:15-0400


#include <iostream>


using namespace std;


int main()
{


	int numbers[100];
	int i = 0;
	int number = 1;
	do {
		cout<<"Enter number: ";
		cin>>number;
		numbers[i] = number;
		i++;
	} while (number != 0);
	i = 0;
	do {
		number = numbers[i];
		cout<<number * number<<"\n";
		i++;
	} while (number != 0);


	system("pause");
	return 0;
}

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