1234
123
12
1
Outer loop 4 times
Inner loop decrements
#include<stdio.h>
int main()
{
int i, j;
for(i=4:i<=1;i--)
{
for(j=1;j<=i;j++)
{
printf("%d", j);
}
printf("\n");
}
return 0;
}
Try the following pattern
4321
432
43
4
Outer loop 4 times
inner loop j=4 and decrement to 1 ( for line no.1 , to 2 for line no.2 and so on. Line no. depend on outer loop variable i)
123
12
1
Outer loop 4 times
Inner loop decrements
#include<stdio.h>
int main()
{
int i, j;
for(i=4:i<=1;i--)
{
for(j=1;j<=i;j++)
{
printf("%d", j);
}
printf("\n");
}
return 0;
}
Try the following pattern
4321
432
43
4
Outer loop 4 times
inner loop j=4 and decrement to 1 ( for line no.1 , to 2 for line no.2 and so on. Line no. depend on outer loop variable i)
No comments:
Post a Comment