We can also have nested for loops, i.e one for loop inside another for loop.
for(initialization; condition; increment/decrement)
{
for(initialization; condition; increment/decrement)
{
statement;
}
}
//Write a C Program which Print Half Pyramid using nested for loop.
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
for(i=1;i<5;i++)
{
printf("\n");
for(j=i;j>0;j--)
{
printf("%d",j);
}
}
getch();
}
Ask Question