Pattern 26 : C Program to print Triangle number pattern 2 using for loops

Triangle Number Pattern 2 :

Write a C program to print below Triangle Number pattern (II).

Example:

Enter how many rows you want : 5
 1 2 3 4 5
 2 3 4 5
 3 4 5
 4 5
 5

Note, That at each row, The Number at the start is removed. So If at first row i have value 1 then at row two my 1 will be removed and 2 will replace it.

Note : This program is one of the Pattern Programs in C

Triangle Number Pattern 2 Program :

Venkatesh

Hi Guys, I am Venkatesh. I am a programmer and an Open Source enthusiast. I write about programming and technology on this blog.

You may also like...

4 Responses

  1. code for above program.
    #include
    int main()
    {
    int i,j,k,n;
    printf("Enter how many rows you want : ");
    scanf("%d",&n);

    for(i=n;i>0;i–)
    {
    for(j=n;j>=i;j–)
    printf(" %d",i);

    printf("n");
    }
    return 0;
    }

  2. Eniya Elango says:

    Write a program to print the given pattern.

    Input Format:
    Input consists of a single integer.

    Output Format:
    Refer sample output. There is a trailing space at the end of each line.

    Sample Input:
    5

    Sample Output:
    5
    4 4
    3 3 3
    2 2 2 2
    1 1 1 1 1

  3. Eniya Elango says:

    Write a program to print the given pattern.

    Input Format:
    Input consists of a single integer.

    Output Format:
    Refer sample outputs. There is a trailing space at the end of each line.

    Sample Input:
    5

    Sample Output:
    5 4 3 2 1
    5 4 3 2
    5 4 3
    5 4
    5

Leave a Reply