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