Pattern printing program 54321 4321 321 using for loop in C
for Loop - Question 15
In this question, we will see how to print the pattern 54321 4321 321... in C programming using for loop. To know more about for loop click on the for loop lesson.
Q15) Write a program in C to print the pattern given below using for loop.
54321 4321 321 21 1
Program
#include <stdio.h>
#include <conio.h>
int main()
{
int r,c;
for(r=5; r>=1; r--)
{
for(c=r; c>=1; c--)
{
printf("%d",c);
}
printf("\n");
}
return 0;
}
Output
54321 4321 321 21 1