0
How to control a loop if you don't know how many times it has to be executed?
I must pass the first letter at the end of each word in a phrase, the phrase will be typed by the user. Also, add "hey" to the end of each word example MI car is red imey arrocey seey ojorey I managed to pass the first letter at the end of each word, but I could not control the cycle so that it only runs the number of times necessary because I do not know how many words the phrase the user will have. this is my result MI car is red imey arrocey seey ojorey hey hey hey hey hey hey
2 Réponses
+ 2
While loop can be useful when you don't know how many times your loop block needs to be executed.
While (condition)
{
statement(s);
}
0
This is the code that I have done so far, but I can't get the loop to only run as many times as necessary
https://code.sololearn.com/c43TGR5l3y8K/?ref=app
I can't get the "hey" to keep repeating when the phrase is over