Search This Blog
Welcome to 1printf(), your ultimate destination for C, C++, Linux, Data Structures, and Microcontroller programming! 🚀 🔹Learn advanced coding techniques in C& C++ 🔹Master Linux internals & shell scripting 🔹Deep dive into Data Structures & Algorithms 🔹Explore Embedded Systems & Microcontrollers (8051,UART, RTOS) 🔹Get hands-on coding tutorials, project ideas,and interview preparation tips Whether you're a beginner or an experienced programmer, this channel will help you
Featured
- Get link
- X
- Other Apps
C Program to Print Descending Number Pattern Using Loops
Descending Number Pattern in C
This C program prints a number pattern where each row contains numbers in ascending order, but the total number of elements decreases with each row. This is done using nested for loops.
✅ C Program Code:
#include <stdio.h>
int main()
{
int num;
printf("Enter the number:\n");
scanf("%d", &num);
for (int i = num; i >= 1; i--)
{
for (int j = 1; j <= i; j++)
{
printf("%d ", j);
}
printf("\n");
}
}
💡 Explanation:
- User Input: The program asks for a number (e.g., 5).
- Outer Loop: Runs from the input number down to 1.
- Inner Loop: Prints numbers from 1 to the current value of
i.
💻 Sample Output:
5
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
🔍 Keywords:
C pattern program, descending number pattern in C, reverse triangle pattern C, number logic in C, beginner friendly C programs, nested loop patterns
Popular Posts
C++ Program for Hybrid Inheritance (All Types Together)
- Get link
- X
- Other Apps
C++ Program for Function Overloading Example
- Get link
- X
- Other Apps
Comments
Post a Comment