Radical Developers welcomes all the visitors to be a member of the team. Come join us. Its all about open-source concept. All Programs are written and tested in MacOS X, Unix, Linux and may not match with the outputs of Turbo C++ in Windows

Sunday, January 9, 2011

Write a program to print the following series :


/* 
1
2 3
4 5 6
7 8 9 10
*/

Source Code :

#include<stdio.h>
void main()
{
      int n,i,j,ctr=1;
      clrscr();
      printf("\nEnter Range : ");
      scanf("%d",&n);
      for(i=1;i<=n;i++)
      {
            for(j=1;j<=i;j++,ctr++)
                  printf("%d ",ctr);
            printf("\n");
      }
      getch();
}

Output :

Enter Range : 4
1
2 3
4 5 6
7 8 9 10

No comments:

Post a Comment