Code Box
------------------------------------------
/*program to print number pattern by while loop
1
12
123
1234
12345
*/
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,j,k;
i=1;
clrscr();
printf("\nEnter a number: ");
scanf("%d",&n);
while(i<=n)
{j=n;
k=1;
while(j>i)
{
printf(" ");
j--;
}
while(k<=i)
{
printf("%d",k);
k++;
}
printf("\n");
i++;
}
getch();
}
------------------------------------------
/*program to print number pattern by while loop
1
12
123
1234
12345
*/
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,j,k;
i=1;
clrscr();
printf("\nEnter a number: ");
scanf("%d",&n);
while(i<=n)
{j=n;
k=1;
while(j>i)
{
printf(" ");
j--;
}
while(k<=i)
{
printf("%d",k);
k++;
}
printf("\n");
i++;
}
getch();
}
No comments:
Post a Comment