This is a nested for loop program in which we are going to see how to print the above pattern of pyramid/triangle of numbers, with the help of the C Programming language.
#include <stdio.h>
int main()
{
int i, j, k, l, n;
printf("Enter the Range\n");
scanf("%d", &n);
for (i = 1; i <= n; i++)
{
for (j = 1; j <= n - i; j++)
{
printf(" ");
}
for (k = 1; k <= i; k++)
{
printf("%d", i);
}
for (l = i - 1; l >= 1; l--)
{
printf("%d", i);
}
printf("\n");
}
return 0;
}
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP