133k views
0 votes
14.18 Lab 5d - Nested Looping Write a program that:

(1) Reads in a string of numbers

(2) Loops through the digits in the string

(3) For each digit in string print that many ' ' on a line.

For example:INPUT:3322 OUTPUT INPUT:4352 OUTPUT:

User Gsinha
by
5.2k points

1 Answer

4 votes

Answer:

Using C++ for the nested looped program.

NOTE: Each digit in string prints '+'

Step-by-step explanation:

#include <iostream>

#include <string>

using namespace std;

int main() {

string s;

cin >> s;

for (int i = 0; i < s.length(); ++i) {

for (int j = 0; j < s[i]-'0'; ++j) {

cout << "+";

}

cout << endl;

}

return 0;

}

User Tore Nestenius
by
5.8k points