C++ program to concatenate a string given number of times
Write a function which returns a new string which is made by concatenating a given string n number of times.
Input : str = "geeks" n = 3 Output : str = "geeksgeeksgeeks" We concatenate "geeks" 3 times Input : str = "for" n = 2 Output : str = "forfor" We concatenate "for" 2 times
This article is contributed by Sahil Rajput. If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Attention reader! Don’t stop learning now. Participate in the Scholorship Test for First-Step-to-DSA Course for Class 9 to 12 students.