C – do…while Loop In a programming language, a loop is useful for running iterative tasks. Using a loop a program can execute code block for multiple times as required. Mainly there are 3 types of loops available in C programming language. Where while loop is one of them. Below is the list if loop available. for loop while loop do-while loop do while Loop A do while loop is similar to while loop. It is exit restricted loops. It means the condition is checked at end of the loop.…
Read MoreTag: while loop
C – while loop
C – while Loop Statement In a programming language, a loop is useful for running iterative tasks. Using a loop a program can execute code block for multiple times as required. Mainly there are 3 types of loops available in C programming language. Where while loop is one of them. Below is the list if loop available. for loop while loop do-while loop while Loop While loop is also an entry-restricted loop. Where a condition is checked before executing the code block. If the condition evaluates to true, the block…
Read MoreBash – While Loop
While Loop in Bash Similar to for loop, while loop is also entry restricted loop. It means the condition is checked before executing while loop. While loop is also capable to do all the work as for loop can do. Syntax: while [condition] do //programme to execute done #1. Bash – While Loop Example For example, the following loop will be executed 5 times and terminated when the value of variable num will be greater than 5.
1 2 3 4 5 6 7 8 | #!/bin/bash num=1 while [ $num -le 5 ] do echo "$num" let num++ done |
#2. Bash – Infinite While Loop Infinite for loops can be also…
Read More