Learn about Pattern Programs in C for Floyd’s Triangle in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.
Pattern Programs in C for Floyd’s Triangle
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Program:
#include<stdio.h>
int main()
{
int n, r, c, a=1;
printf("Enter number of rows: ");
scanf("%d", &n);
for(r=1; r<=n; r++)
{
for(c=1; c<=r; c++)
printf("%5d",a++);
printf("\n");
}
return 0;
}
Output:
Enter number of rows: 5 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.
Similar Codes :
Half Pyramid using Numbers in C
C program Half Pyramid using *, Increment & Decrement Operators