Answer to Question #130542 in C++ for Zaib Mk

Question #130542
Develop a program following format for using while loop?


===========================
a b
1 5
2 4
3 3
4 2
5 1
============================
1
Expert's answer
2020-08-24T16:29:47-0400
#include <iostream>

using namespace std;

int main() {

    int a = 1, b = 5;
    cout << "----------\n";
    cout << ("a\tb\n");
    cout << "----------\n";
    while (a <= 5) {

        cout << a << "\t" << b << endl;
        a++;
        b--;
    }
    cout << "----------\n";

}

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
APPROVED BY CLIENTS