Introduction To Programming

Why programs ? Programming is nothing but making the computers think the same way a human thinks. Programs are made for obtaining a specific solution which can even be solved by humans which when solved by us may consume time..

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");

  }
}