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 Print Right Half Pyramid pattern

c program

C Program  Print Right Half Pyramid pattern


C Program  Print Right Half Pyramid pattern

Examples :-     


#include<stdio.h>
#include<conio.h>
int main()
{
int i,j,row;
printf("enter the number");
scanf("%d",&row);
for(i=1;i<=row;i++)
{
for(j=1;j<=i;j++)
{
printf("*");
}
printf("\n");
}
return 0;
}



C Program  Print Right Half Pyramid pattern

 Program Output 

Q.1] C Program  Print Right Half Pyramid pattern   Program Output

C Program  Print Right Half Pyramid pattern

Explain Program

Step 1 ]  

#include<conio.h>

 input/output  functions like printf() and scanf()

Step 2

int main()

 function, the entry point of your C program.

Step 3

int i, j, row;

Declares three integer variables 

i: outer loop counter (for rows) 

j: inner loop counter (for printing *) 

row: stores the number of rows entered by the user

Step 4

printf("enter the number");

 user to input the number of rows.

Step 5

scanf("%d", &row);

Takes input from the user and stores it in the row variable. 

%d is for reading an integer. 

&row means you're passing the address of the variable row to store the user input.

Step 6

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

This is the outer loop. 

It runs from 1 to the number entered by the user (row).

Step 7

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

This is the inner loop. 

For each row i, it prints i number of asterisks *.

Step 8

 printf("*");

Prints a single asterisk * without moving to the next line.

Step 9

printf("\n");

 moves the cursor to the next line.


Related Post :-

javascript assignment operators

PHP Program to print Alphabet 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