Inverted Half Pyramid Pattern in C

Inverted Half Pyramid Pattern in C language for beginners. Using this program we can understand the for loop concept in c program.

For Loop in C Program

A for loop is a repetition control structure that lets you design a loop that needs to run a certain number of times quickly. The initialization statement explains the loop’s start point, where the loop variable is set to a default value. 

A loop variable, often known as a counter, is a variable that controls the loop’s flow. The condition till the loop is repeated is the test expression. For loops will iterate over a piece of code for a predetermined number of times. The name for loops comes from the fact that you may tell your app how many times it should repeat the code.

Integer Data Type in C

In computer programming, an integer is a data type that is used to represent real numbers that do not contain fractional values. Different sorts of integer data types are stored in different ways on devices. The collection of whole numbers and their opposites is known as the integers. The set of integers does not include fractions or decimals.

#include <stdio.h> 
void main() 
{ 
int i, j, rows; 
printf (" Enter the number of rows \n "); 
scanf("%d", &rows); 
printf("\n"); 
for (i = rows; i > 0; i--) 
{ 
for (j = i; j > 0; j--) 
{ 
printf ("* "); 
} 
printf ("\n"); 
} 
} 

Output:

Enter the number of rows
5

* * * * *
* * * *
* * *
* *
*