C Language Nested Loops Set 8

Get the following output:

* * * * *
* * * *
* * *
* *
*

#include <stdio.h>
int main()
{
    int i,j;
    for(i=5;i>=1;i=i-1)
    {
        for(j=1;j<=i;j=j+1)
        {
            printf("* ");
        }
        printf("\n");
    }
    return 0;
}

Get the following output:

1
2 1
3 2 1
4 3 2 1
5 4 3 2 1

#include <stdio.h>
int main()
{
    int i,j;
    for(i=1;i<=5;i=i+1)
    {
        for(j=i;j>=1;j=j-1)
        {
            printf("%d ",j);
        }
        printf("\n");
    }
    return 0;
}

Get the following output:

1
3 1
5 3 1
7 5 3 1
9 7 5 3 1

#include <stdio.h>
int main()
{
    int i,j;
    for(i=1;i<=5;i=i+1)
    {
        for(j=i;j>=1;j=j-1)
        {
            printf("%d ",j*2-1);
        }
        printf("\n");
    }
    return 0;
}

C Language Programming Tutorial

C Language Tutorial Home    Introduction to C Language     Tokens     If Condition     goto statement and Labelname     Switch Statements     For loop     While Loop    Do while loop     break and continue    Functions    Recursion    Inbuild Functions    Storage Classes    Preprocessor    Arrays    Pointers     Structures and Unions    File Handling     Projects