Purchase Solution

Three different looping examples in C++

Not what you're looking for?

Ask Custom Question

Design a While Loop that lets the user enter a number. The number should be multiplied by 10, and the result stored in a variable named product. The loop should iterate as long as product contains a value less than 100.

Design a For loop that calculates the total of the following series of numbers: 1/30+2/29+3/28+...30/1

Design a program with a loop that lets the user enter a series of numbers. Then user should enter -99 to signal the end of the series. After all the numbers have been entered, the program should display the largest and smallest numbers entered.

Purchase this Solution

Solution Summary

This solution provides three different examples of using loops in C++.

Solution Preview

For this posting I'll assume C++ but the loop concepts are nearly universal for the different common programming languages.

The following while loop reads in integers as long as the product of the entered number * 10 is less than 100.

int num;
int product = 0;
while (product < 100) {
cin >> num;
product = num * 10;
}

The loop ...

Purchase this Solution


Free BrainMass Quizzes
Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.

Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.

C# variables and classes

This quiz contains questions about C# classes and variables.

C++ Operators

This quiz tests a student's knowledge about C++ operators.

Java loops

This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.