C Language "Floyd's triangle pattern using for loop" program with output
#include <stdio.h>
int main() { int n, num = 1; printf("Enter the number of rows for Floyd's triangle: "); scanf("%d", &n); printf("Floyd's triangle with %d rows:\n", n); for (int i = 1; i <= n; i++) { for (int j = 1; j <= i; j++) { printf("%2d ", num); num++; } printf("\n"); } return 0; }Output
Enter the number of rows for Floyd's triangle: 4
Floyd's triangle with 4 rows:
1
2 3
4 5 6
7 8 9 10
Comments
Post a Comment