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 Half Pyramid Using Numbers pattern

C Program Print Half Pyramid Using Numbers pattern


C Program  Print Half Pyramid Using Numbers pattern
Example 


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

}


C Program  Print Half Pyramid Using Numbers pattern
Explain Program

Step :1

#include<stdio.h>

  • standard input-output header file use printf() and scanf().

Step :2

void main()

  • main function  execution starts.

Step :3

 Variable Declarations

int i, j, r;

  • r: Number of rows for the pattern (user input).
  • i: Controls the outer loop (rows).
  • j: Controls the inner loop (columns/numbers in each row).

Step :4

printf("enter the number");

scanf("%d", &r);

  •  user to enter the number of rows.

Step :5

Outer Loop – Controls the Rows

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

  • Starts 1 and goes up to r.
  • Each iteration print one row of the triangle.

Step :6

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

{

    printf("%d", j);

}

  •  each row i, it prints numbers from 1 to i.

Step :7

printf("\n");

cursor to the next line

Step :8

return 0;

C Program Print Half Pyramid Using Numbers pattern
 Program Output :- 


Number Pattern Program in C


Related Post :-

Comments

Popular posts from this blog

HTML Tag

CSS Text Color Explained with Syntax and HTML Examples

HTML Input Type Submit Syntax and Example