Pascal triangle in C
suggest change#include <stdio.h>
int main(void) {
const int rows = 5;
for (int row = 1; row <= rows; ++row) {
int value = row;
for (; value < 2 * row; ++value) {
printf("%s%d", value == row ? "" : " ", value);
}
for (value -= 2; value >= row; --value) {
printf(" %d", value);
}
putchar('\n');
}
return 0;
}
1
2 3 2
3 4 5 4 3
4 5 6 7 6 5 4
5 6 7 8 9 8 7 6 5
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents