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:

Answer :

Answer:

Using C++ for the nested looped program.

NOTE: Each digit in string prints '+'

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;

}

Other Questions