Conditional Rendering in React Complete Guide with Examples 2026

Image
  Conditional Rendering in React Conditional Rendering is one of the most useful concepts in React. It means showing different content on the screen depending on a condition. For example: If a user is logged in → show Logout If a user is not logged in → show Login If a student has passed → show Congratulations If a product is available → show Buy Now If data is loading → show Loading... React does not have a separate if rendering tag. Instead, we use normal JavaScript conditions such as if, the ternary operator, &&, and switch to decide what should appear in the UI.

C Program to Print Inverted half Pyramid of Number

C Program to Print Inverted half Pyramid


C Program to Print Inverted half Pyramid  of Number
Example 


#include<stdio.h>
void main ()
{
int i,j,r;

printf("enter the number");
scanf("%d",&r);
for(i=r;i>=1;i--)
{
for(  j=1;j<=i;j++)
{
printf("%d",j);
}
printf("\n");
}
return 0;
}


C Program to Print Inverted half Pyramid  of Number
Explain Program

Step :1

#include <stdio.h>

 standard input/output library.

Step :2

void main()

 main function where the program starts.

Step :3

Variable Declarations

int i, j, r;

r: The number of rows (user input).

i: Controls the outer loop (rows).

 j: Controls the inner loop (columns/numbers per row).

Step :4

printf("enter the number");

scanf("%d", &r);

 user to enter an integer value r

 the number of rows in the pattern

Step :5

Outer Loop (Row Control)

for(i = r;  i >= 1;  i--)

Start  from i = r and decrements down to 1.

Each iteration represent one row in the output.

 number of values printed in a row equals i.

Step :6

for(j = 1; j <= i; j++)

{

    printf("%d", j);

}

each row, this loop prints numbers starting from 1 up to i.

Step :7

printf("\n");

row move the cursor to the next line.

Step :8

return 0;

C Program to Print Inverted half Pyramid  of Number
 Program Output :- 


C Program to Print Inverted half Pyramids  of Number

Related Post :-

C Program Print Right Half Character Pyramid Pattern

C program print square star pattern


Comments

Popular posts from this blog

HTML Tag

CSS Text Color Explained with Syntax and HTML Examples

HTML Input Type Submit Syntax and Example