Saturday, December 31, 2011

Print following pattern in 'C'


1
12
123
1234

Example



#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,n;
clrscr();
printf("Enter the value of n:");
scanf("%d",&n);
for(i=0;i<=n;i++)
{
for(j=1;j<i;j++)
{
printf("%d",j);
}
printf("\n");
}
getch();
}
/*=====================================================================
OUTPUT
Enter the value of n:5


1
12
123
1234
*/


No comments:

Post a Comment