NESTED FOR STATEMENT:
If one for statement is completely placed with in the other.
POINTS TO REMEMBER:
- One loop must completely be placed inside the other loop means no overlapping of loops.
- Each loop must have different variables.
#include<conio.h>
void main()
{
int i, j;
int i, j;
num=5;
clrscr();
printf(" Number Pattern\n);
for( i=num ; i>=1 ; i--)
{
for(j=1 ; j<=i ; j++)
{
printf(" %d" , num) ;
}
/* End of j Loop */
/* End of j Loop */
printf(" \n");
num-- ;
}
/* End of i Loop */
/* End of i Loop */
} /* End of main() */
Output:
Number Pattern
5 5 5 5 5
4 4 4 4
3 3 3
2 2
1
0 Response to "Write a C Program to Print The Given Number Pattern by using Nested for Loop"
Post a Comment