R Repeat - r - learn r - r programming
- In general, the Repeat loop executes the same condition many times until a stop condition is satisfied.
- A repeat loop is used to iterate over a block of code multiple number of times.
Syntax
Sample Code
Code Explanation
- x specifies to string variable. Here x is initialized to value as 1.
- Here print() is used to print the value and that value stored in x variable.
- x = x+1, which means the x = 1 is incremented by 1 and becomes 9. If the condition to check and exit the loop when x takes the value of 10. Here break statement is used to exit the loop.
Output
- Here we have used a condition to check and exit the loop when x takes the value of 10. Hence, we have displayed the output that only values from 1 to 9 get printed.