print the pyramid of digits in pattern


//Write a C program to print the pyramid of digits in pattern.

#include <stdio.h>

main()

{

int i,s,r,k=0,count,count1;

count=0;

count1=0;

printf(“Enter the number of rows: “);

scanf(“%d”,&r);

for(i=1;i<=rows;++i)   /*loop for rows*/

{

for(s=1;s<=r-i;s++) /* loop for space*/

{

printf(” “);

count++;

}

while(k!=2*i-1)

{

if (count<=r-1)

{

printf(“%d “,(i+k));

count++;

}

else

{

count1++;

printf(“%d “, (i+k-2*count1));

}

k++;

}

count1=count=k=0;

printf(“\n”);

}   }

Related Posts

Comments are closed.