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 Hollow Full Pyramid Using Stars Pattern

C Program to print Hollow Full pyramid star Pattern

C Program to Print Hollow Full Pyramid Using Stars Pattern



C Program to print Hollow Full pyramid star Pattern

Example :-


#include<stdio.h>
int main()

{
int i, space, row, star=0;


printf("Enter The Number ");
scanf("%d",&row);


for(i = 0; i < row-1; i++) {
for(space = 1; space < row-i; space++) {
printf(" ");
}


for (star = 0; star <= 2*i; star++) {
if(star==0 || star==2*i)


printf("*");
else
printf(" ");
}
printf("\n");
}


for(i=0; i<2*row-1; i++){
printf("*");


}
return 0;
}


C Program to Print Hollow Full Pyramid Using Stars Pattern

Explain Program

Step :1

#include <stdio.h>

int main()

{

    int i, space, row, star = 0;


#include <stdio.h> :-  printf and scanf.

 int i, space, row, star;: Declares loop variables and input variable.

 row = number of levels of the pyramid.

 i = controls outer loop (rows).

 space = manages indentation before the stars.

 star = controls how many positions are printed per row.

Step :2

User Input

printf("Enter The Number ");

scanf("%d", &row);

User input how many rows they want for the pyramid.

 If input is 5, the pyramid 

Step :3

Hollow Pyramid

for(i = 0; i < row - 1; i++) {

    for(space = 1; space < row - i; space++) {

        printf(" ");

    }

     for(star = 0; star <= 2 * i; star++) {

        if(star == 0 || star == 2 * i)

            printf("*");

        else

            printf(" ");

    }

     printf("\n");

}

How it work:

  •  Loop 1)  for (i = 0; i < row - 1; i++)
  • Controls each row of the hollow pyramid .
  •  Runs row - 1 times (e.g., if row = 5, this loop runs 4 times).
  •  Loop 2)  for (space = 1; space < row - i; space++)
  • Adds spaces to align the stars in a pyramid shape.

Step :4

for(star = 0; star <= 2*i; star++)

Handle the character in the current row.

Always print * at the start (0) and end (2*i).

 In between, print a space to make it hollow.

 Step :5

Bottom Part:

for(i = 0; i < 2 * row - 1; i++) {

    printf("*");

}

loop prints a full base of stars at the bottom.


C Program to print Hollow Full pyramid star Pattern
Output :-

C Program to print Hollow Full pyramid star Pattern

Related Post :-

C program t -prin rhombus star pattern

c program to print floyds triangle

c program to print pascals triangle

Comments

Popular posts from this blog

HTML Tag

CSS Text Color Explained with Syntax and HTML Examples

HTML Input Type Submit Syntax and Example