[Solved] How to repeat the string in C++? [closed]


If you may not use a loop, you may use goto to get around the restriction:

#include <iostream>
#include <string>
using namespace std;

int main()
{
  int N;

  cout << "Enter N: ";
  cin  >> N;

  {
    int i = 0;
    goto test;
    begin:
    cout << "Well Done";
    ++i;
    test:
    if (i < N)
      goto begin;
  }
  return 0;
}

Note that goto is widely considered bad practice.

9

solved How to repeat the string in C++? [closed]