Chapter 5: Problem 24
Write a loop that asks the user to enter a number. The loop should iterate 10 times and keep a running total of the numbers entered.
Chapter 5: Problem 24
Write a loop that asks the user to enter a number. The loop should iterate 10 times and keep a running total of the numbers entered.
All the tools & learning materials you need for study success - in one app.
Get started for freeWrite a do-while loop that asks the user to enter two numbers. The numbers should be added and the sum displayed. The user should be asked if he or she wishes to perform the operation again. If so, the loop should repeat; otherwise it should terminate.
A loop that does not have a way of stopping is a(n) __________ loop.
include \(<\)
iostream \(>\) using namespace std; int main() \\{ int choice, num1, num2; do
\\{ cout \(<<\) "Enter a numbe…
#
A) / / This program displays the sum of two numbers. # include \(<\) iostream
\(>\)
using namespace std;
int main()
\\{
int choice, num1, num2;
do
\\{
cout \(<<\) "Enter a number: ";
\\[
\operatorname{cin} \quad>>\text { num1 }
\\]
cout \(<<\) "Enter another number: "
\\[
\operatorname{cin} \quad>>\text { num2 }
\\]
cout \(<<\) "Their sum is " \(<<(\text { num1 }+\text { num2 ) }<<\) endl; cout
\(<<\) "Do you want to do this again?
\\[
\begin{array}{l}
\text { cout }<<" 1=\text { yes, } 0=\text { noln" } \\
\text { cin }>>\text { choice }
\end{array}
\\]
}while (choice = 1) return 0
\\}
B) // This program displays the sum of the numbers \(1-100\) # include
include
\(<\) iostream \(>\) using namespace std; int main ( ) \(\\{\) int num, bigNum,
power, count; cout \(<<\) "…
#
A) // This program uses a loop to raise a number to a power. # include \(<\)
iostream \(>\) using namespace std; int main ( )
\(\\{\) int num, bigNum, power, count;
cout \(<<\) "Enter an integer: "; \(\operatorname{cin} \quad>>\) num
cout \(<<\) "What power do you want it raised to? "; cin \(>>\) power bigNum \(=\)
num; while (count++ \(<\) power); bigNum \(*=\) num; cout \(<<\) "The result is \(<<\)
bigNum \(<<\) endl return 0
\\}
B) // This program averages a set of numbers. # include
To __________ a value means to increase it by one.
What do you think about this solution?
We value your feedback to improve our textbook solutions.