Code Box
---------------------------------------
/*program to print number pattern by while loop
1
21
321
4321
54321
*/
#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=i;
while(j>i)
{
printf(" ");
j--;
}
while(k>=1)
{
printf("%d",k);
k--;
}
printf("\n");
i++;
}
getch();
}
No comments:
Post a Comment