94
R while loop
A while loop is a type of control flow statements which is used to iterate a block of code several numbers of times. The while loop terminates when the value of the Boolean expression will be false.
In while loop, firstly the condition will be checked and then after the body of the statement will execute. In this statement, the condition will be checked n+1 time, rather than n times.
The basic syntax of while loop is as follows:
Flowchart
Example 1:
Output
Example 2: Program to find the sum of the digits of the number.
Output
Example 3: Program to check a number is palindrome or not.
Output
Example 4: Program to check a number is Armstrong or not.
Output
Example 5: program to find the frequency of a digit in the number.
Output
Next TopicR Functions