Answer to Question #204197 in C++ for Nethu

Question #204197


c++ programming

Write only the do while loop statements to print the following sequences.

1) 28 21 15 10 6 3 1 0

2) 12 11 9 6 2 -3​


1
Expert's answer
2021-06-07T07:04:32-0400
#include <iostream>
using namespace std;

int main() {
    int x, dx;

    // 1
    x = 36;
    dx = 8;
    do {
        x -= dx;
        cout << x << " ";
    } while (--dx > 0);
    cout << endl;

    // 2
    x = 12;
    dx = 0;
    do {
        x -= dx++;
        cout << x << " ";
    } while (x > 0);
    cout << endl;
}

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