Answer to Question #286355 in C++ for Ayesha

Question #286355

Program all natural number from 1 to n using while loop

1
Expert's answer
2022-01-11T06:05:14-0500
#include <iostream>
using namespace std;

int main() {
    int i, n;

    cin >> n;
    i = 1;

    while (i<=n) {
        cout << i << endl;
        i++;
    }

    return 0;
}

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