Techy Blitz

The science of today is the technology of tomorrow.

Breaking

Thursday, 22 November 2018

C Program to print a pyramid



#include <stdio.h>
int main(void)
{
// n is number of rows // PRAJNADEEP
int n = 5;
int i, j, k;

// do for each row
for (i = 1; i <= n; i++)
{
// print space
for (j = i; j < n; j++)
printf(" ");

// print '*'
for (k = 1; k < 2*i; k++)
printf("*");

// move to the next line
printf("\n");
}

return 0;
}