Friday, July 22, 2011

Program to print numbers in Traingular pattern {Type 1}


1
1  2
1  2  3
1  2  3  4
1  2  3  4  5

----------------------------------------------------
/*Serial No.22     [swami143.cpp]*/

/* this program prints numbers in traingular fashion.(up to which no. u want)*/
#include<stdio.h>
#include<conio.h>
int i,j,n;
void main()
{
clrscr();
printf("Enter the no. upto which u want to print numbers.:");
scanf("%d",&n);
printf("\n");
for(i=1;i<=n;i++)
{printf("%d\n",i);
if(j==n)
break;
for(j=1;j<=i;j++)
printf("%d ",j);
}
getch();
}

No comments:

Post a Comment

If you have any doubt, feel free to ask...