Table of Contents
In this tutorial, we will discuss the Nested while in C programming language.
initially, the outer while evaluates the test Expression
When the condition is true, it executes the body of statements of the outer loop and the loop control move to the inner loop and statements inside the body of the inner loop is executed.This process repeats until the test expression of the inner while loop is false.
Then, when the test expression of the inner while loop is false. control exits from the inner loop and moves to outer loop again
then the loop-control evaluates the test condition of the outer while loop
The test condition of outer loop returns true, the loop control executes the body of while loop statements and move to the inner loop
Outer while loop return as false the loop control exit from the loop and goes to rest
Here we can see a while loop inside the body of another while loop.
Program 1
Output
0123456789
0123456789
0123456789
0123456789
0123456789
0123456789
0123456789
0123456789
0123456789
0123456789
Program 2
Output
1 2 3 4 5 6 7 8 9
2 4 6 8 10 12 14 16 18
3 6 9 12 15 18 21 24 27
4 8 12 16 20 24 28 32 36
5 10 15 20 25 30 35 40 45
6 12 18 24 30 36 42 48 54
7 14 21 28 35 42 49 56 63
8 16 24 32 40 48 56 64 72
9 18 27 36 45 54 63 72 81
Prpgram 3
Print a multiplication table using nested while loop
Multiply two numbers in Java using scanner| 5 different ways In this article, we will…
5 Different ways to Divide two numbers in Java using scanner In this article, we…
Learn 8 Ways to Subtract Two Numbers Using Methods in Java In this article, we…
10 ways to subtract two numbers in Java In this article, we will discuss the…
Java Code Examples – Multiply Two Numbers in 5 Easy Ways In this article, we…
How to Divide two numbers in Java| 5 different ways In this article, we will…
This website uses cookies.