Computer Science, asked by jyotybharatsoni, 4 days ago

write a program to accept a string and display it as many times as the user wants.​

Answers

Answered by ArishMir22
2

Answer:

count number of times. Print “Empty string” in case of any unsatisfying conditions. (Given character is not present, or present but less than given count, or given count completes on last index). If given count is 0, then given character doesn’t matter, just print the whole string.

Examples:

Input : str = "This is demo string"

char = i,

count = 3

Output : ng

Input : str = "geeksforgeeks"

char = e,

count = 2

Output : ksforgeeks

Asked in: Oracle

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.

In case you wish to attend live classes with experts, please refer DSA Live Classes for Working Professionals and Competitive Programming Live for Students.

Recommended: Please solve it on “PRACTICE ” first, before moving on to the solution.

Implementation:

1- Start traversing the string.

Increment occ_count if current char is equal to given char.

Get out of the loop, if occ_count becomes equal to given count.

2- Print the string after the index till the string gets traversed in

Similar questions