# pattern 25: C program to print 12345 number pattern ( Inverted triangle number pattern )

## Inverted triangle number pattern Program:

Write a C Program to print the Inverted triangle number pattern using loops.

The program will take one input number from the user. Which is the number of rows for the pattern.

Here is an Example of desired pattern, When user input row size is 5.

Example:

Enter how many rows you want : 5

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

Few browsers not showing the pattern properly, Here is the pattern in Image format. Note : This program is one of theSeries of Number pattern programs in C.

## Program Logic:

We are going to use the two for loops to create the pattern. The First for or Outer for loop is used to display the row numbers. And the second for loop or Inner for loop is useful to display the column numbers.

Here is the main logic

• As it is Inverted Triangle pattern, Our outer for loop starts from the 'n' e input row size) and goes down upto the
• At each iteration of outer loop, The inner loop goes from 1 to  'i'  ( Here  'i'  outer loop iterator).
• So as we are stopping the iteration at 'i' e are creating the Triangle shape.

## Program Output:

We used GNU GCC compiler to compile and run the program.

### Similar Star pattern programs : Venkatesh

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

### 6 Responses

1. Venkatesh Macha says:

int main()
{
int i,j,k,n;
printf("Enter how many rows you want : ");
scanf("%d",&n);

for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
printf(" %d",i);

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

2. Venkatesh Macha says:

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=i;j<=n;j++)
printf(" %d",j);

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

3. Venkatesh Macha says:

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

for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
printf(" %d",j);

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

4. Eniya Elango says:

Pattern 7
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:
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5

5. Eniya Elango says:

Pattern 6
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 5
3 4 5
2 3 4 5
1 2 3 4 5

6. 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:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5