The basics of programming in c++ for beginners

Tasks: while loops, do while, nested loops

We met with loops while and do while in C++ and c nested constructions in loops. Let us tasks solving.

1. Organize continuous input of numbers with the keyboard, until the user has entered 0. After entering a zero, show on the screen the number of numbers, which were introduced, their total amount and the arithmetic mean. Tip: you must declare the counter variable, that will count the number of entered numbers, and variable, that will accumulate a total sum of numbers.

2. It is necessary to sum up all the odd integers, which will introduce the user to the keyboard.

3. The task is more difficult. Draw an isosceles triangle of characters ^. The height of a user selects. For example: height = 5, on the screen

task nested loops

Read how to determine the mobile browser javascript.

Tasks: while loops, do while, nested loops
4.9 (98.89%) 18 vote[s]

116 thoughts on “Tasks: while loops, do while, nested loops

  1. Hi!
    Here is my simplified version. I copied the wrong top)

    int main()
    int height;
    cout <> height;
    for (int i = 1; i <= height; i )
    for (int j = 1; j = height – i + 1) && (j <= height + i – 1)) ? cout << "^" : cout << " ";
    cout << endl;
    return 0;

  2. Write a program, which print a body depending on the time, if it falls from a height H from the initial skorostyuV0. Count the number of time points, when the current altitude mensheH / 2.

Leave a Reply to GalizMan Cancel reply

Your email address will not be published. Required fields are marked *