Search This Blog

Thursday, October 13, 2011

Write a Program to Give output

1
1 2
1 2 3


   1:  #include<stdio.h>
   2:  #include<conio.h>
   3:  void main()
   4:  {
   5:  int i,j,n,s;
   6:  printf("Enter the num of rows:\n");
   7:  scanf("%d",&n);
   8:  for(i=1;i<=n;i++)
   9:      {
  10:      for(s=n-i;s>=1;s--)
  11:          {
  12:          printf(" ");
  13:          }
  14:      for(j=1;j<=i;j++)
  15:          {
  16:          printf("%d ",j);
  17:          }
  18:      printf("\n");
  19:      }
  20:  getch();
  21:  }

No comments:

Post a Comment