Sunday, January 1, 2012

Print following pattern. 1 22 333 4444 in 'C'


1
22
333
4444

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",i);
}
printf("\n");
}
getch();
}
/*=====================================================================
OUTPUT
Enter the value of n:4


1
22
333
4444



8 comments:

  1. there's an error I = 1 but not I = 0

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. program question is not that first enter number and then prints 1 22 33 444 it is just printing all numbers kindly explain?

    ReplyDelete