Reverse order number pattern in C using for loop
- Home
- Floyd's triangle
- Reverse order number pattern in C using for loop
- On
- By
- 2 Comments
- Categories: Floyd's triangle, Number pattern
Reverse order number pattern in C using for loop
Reverse order number pattern in C using for loop
In this tutorial, we will discuss a concept of Reverse order number pattern in C using for loop
In C language, we can use for loop, while loop, do-while loop to display various number, star, alphabet and binary number patterns
In this topic, we demonstrate how to display some reversed number patterns using the nested while loop in C language.
Pattern 1
Reverse order number pattern program 1
#include <stdio.h> #include <stdlib.h> int main() { int i,j,rows;//variable declaration printf("Enter the number of rows: "); scanf("%d",&rows);//get input from user for(i=rows; i>=1; i--){//outer for loop for(j=i; j>=1; j--){//inner for loop printf("%d",i);//print pattern } printf("\n");//move to next line } getch(); return 0; }
When the above code is compiled and executed, it produces the following results
Enter the number of rows: 6 666666 55555 4444 333 22 1
Pattern 2
Reverse order number pattern program 2
#include <stdio.h> #include <stdlib.h> int main() { int i,j,rows;//variable declaration printf("Enter the number of rows:\n "); scanf("%d",&rows); printf("\n");//takes input from user for(i=1; i<=rows; i++){ for(j=i; j>=1; j--){ printf("%d",j);//display pattern } printf("\n");//move to next line } getch(); return 0; }
When the above code is compiled and executed, it produces the following results
Enter te number of rows: 8 1 21 321 4321 54321 654321 7654321 87654321
Pattern 3
Reverse order number pattern program 3
#include <stdio.h> #include <stdlib.h> int main() { int i,j,rows;//variable declaration printf("Enter the number of rows: "); scanf("%d",&rows);//takes input from user for( i=rows; i>=1; i--){ for( j=rows; j>=i; j--){ printf("%d",j); printf(" "); } printf("\n");Move to next line } return 0; }
When the above code is compiled and executed, it produces the following results
Enter the number of rows: 8 8 8 7 8 7 6 8 7 6 5 8 7 6 5 4 8 7 6 5 4 3 8 7 6 5 4 3 2 8 7 6 5 4 3 2 1
Similar post
Java program to print star pyramid pattern
C program to print star pyramid pattern
C++ program to print star pyramid pattern
Python program to print star pyramid pattern
Floyd’s triangle number pattern using for loop in C
Floyd’s triangle pattern using nested for loop in Java
Floyd’s triangle pattern using nested while loop in Java
Hollow pyramid triangle pattern in C++ language
Rhombus pattern in Java using for loop
Rhombus pattern in C using while loop
Rhombus pattern in C++ using do-while loop
Suggested for you
Do-while loop in Java language
Nested for loop in Java language
Nested for loop in C++ language
Nested for loop in Python language
2 Comments
suruthi July 16, 2020 at 4:08 pm
01 02 03 04 05 26 27 28 29 30
06 07 08 09 22 23 24 25
10 11 12 19 20 21
13 14 17 18
15 16
can anyone help me solve this code
Shlok paghdal October 4, 2021 at 5:54 pm
12345
2345
345
45
5
HELP ME PLEASE!!
=D