C Programming

C Programming


How to make continuous number pyramid with Zero

Posted: 17 Feb 2015 08:46 AM PST

Q. Write a C program to make a continuous number pyramid with adding digit "Zero" as:

  1
  02
  003
  0004
  00005
  000006
  0000007
  00000008
  000000009

Ans.

/*c program for making a continuous number pyramid*/
#include<stdio.h>
int main()
{
 int r,c;

 printf("1\n");
 for(r=2; r<=9; r++)
 {
   for(c=1; c<=r; c++)
   {
      if(c==r)
         printf("%d",r);
      else
         printf("0");
   }
   printf("\n");
 }
 getch();
 return 0;
}

/***********************************************************
The output of above program would be:
***********************************************************/

Output of How to make continuous number pyramid  with Zero C Program
Figure: Screenshot for How to make continuous number pyramid
 with Zero C Program


You might also like:

  1. Big list of 98+ C Pyramid programs
  2. Latest pyramid programs list asked by user



Post a Comment