n = 5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include <stdio.h>
int main() {
int rows = 5; // Number of rows in the triangle
int num = 1; // Counter to keep track of consecutive numbers
for (int i = 1; i <= rows; i++) { // Loop for rows
for (int j = 1; j <= i; j++) { // Loop for columns in each row
printf("%d ", num);
num++; // Increase counter
}
printf("n"); // Move to next row
}
return 0;
}
#include <stdio.h>
int main() {
int rows = 5; // Number of rows in the triangle
int num = 1; // Counter to keep track of consecutive numbers
for (int i = 1; i <= rows; i++) { // Loop for rows
for (int j = 1; j <= i; j++) { // Loop for columns in each row
printf("%d ", num);
num++; // Increase counter
}
printf("n"); // Move to next row
}
return 0;
}