Wednesday, December 15, 2010

Coding to create a pyramid using numbers in c program

#include<stdio.h>
void main()
{
 int n;
 do
 {
  printf("How many lines you want to printn");
  scanf("%d",&n);
 }
  while((n<1)||(n>9));
  for(int i=1;i<=n;i++)
  {

   for(int j=1;j<=(n-i);j++)
   printf(" ");

   for(j=1;j<=i;j++)
                        printf("%d",j);    

                        for(j=(i-1);j>=1;j--)
   printf("%d",j);

   printf("n");

  }
}

1 comments:

I am new guy for this c program. After work out this program i learned some c techniques. It's really helpful to me.

website hosting india

Post a Comment