TRIANGLE

#include
int main() {
int i, j, k, c = 5;
for (i = 1; i <= 5; i++) {
/* k is taken for spaces */
for (k = 1; k <= c; k++) {
/* blank space */
printf(" ");
}
for (j = 1; j <= i; j++) {
/* %2d ensures that the number is printed in two spaces for alignment and the numbers are printed in the order. */
printf("%2d", i);
}
printf("\n");
/*c is decremented by 1 */
c--;
}
return 0;
}

Comments

Popular Posts