In this tutorial, we will discuss the concept of C program to reverse triangle number patterns using while 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
#include <stdio.h> #include <stdlib.h> int main() { int j,rows;//variable declaration printf("Enter the number of rows:\n "); scanf("%d",&rows);//take input from user printf("\n"); while(rows>=1){//outer while loop int j=rows; while(j>=1){//inner while loop printf("%d",j);//Display pattern j--; } rows--; printf("\n");//move to next line } getch(); return 0; }
When the above code is executed, it produces the following results
Enter the number of rows: 8 87654321 7654321 654321 54321 4321 321 21 1
Pattern 2
#include <stdio.h> #include <stdlib.h> int main() { int j,rows;//variable declaration printf("Enter the number of rows: "); scanf("%d",&rows); printf("\n"); int i; while(rows>=0){ for(i=1; i<=rows; i++){ printf("%d",rows); } rows--; printf("\n"); } getch(); return 0; }
When the above code is executed, it produces the following results
Enter the number of rows: 8 88888888 7777777 666666 55555 4444 333 22 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
C# inverted full pyramid star pattern In this article, we will discuss the concept of…
C# Full Pyramid star pattern program In this article, we will discuss the concept of…
Program to count vowels, consonants, words, characters and space in Java In this article, we…
How to print multiplication table using Array in C++ language In this post, we will…
C Program to multiplication table using Array In this tutorial , we will discuss about…
Java program to check odd or even using recursion In this tutorial, we discuss a…