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.

How to Display T Pattern in C with Star (*) – Step-by-Step

How to Display T Pattern in C with Star (*) – Step-by-Step


 C program to Print  Alphabet  T  Using star pattern  

Example 


#include <stdio.h>

int main() {
    int a, b;
    int n = 7; // height of the T

    for (a = 0; a < n; a++) {
        for (b = 0;  b< n; b++) {
            // Print * for the top bar and vertical middle bar
            if (a == 0 || b == n / 2)
                printf("*");
            else
                printf(" ");
        }
        printf("\n");
    }

    return 0;
}


C Program to Print T Pattern 
Explain Program

Step 1 ]  

 #include <stdio.h>

int main() {

    int a, b;

    int n = 7; 

 height of the T
n is set to 7, which means the height of the "T" will be 7 rows  variable a and b  are use as loop.

Step 2 ]  

Outer Loop – Rows

for (a = 0; a < n; a++) {

This loop iterates from 0 to 6 (total 7 times),

 each iteration representing one row of output.

Step 3]  

Inner Loop – Columns

    for (b = 0;  b< n; b++) {


For each row, this loop iterates 7 times (columns from 0 to 6).

Step 4]  

Conditional Statement


        if (a == 0 || b == n / 2) 
            printf("*");
        else
            printf(" ");
            printf("*");
        else
            printf(" ");

a == 0: For the first row, print a * in every column — this forms the top horizontal bar of the "T".

b == n / 2: For all rows, 
print a * in the middle column (
since n = 7, n / 2 = 3) — this forms the vertical bar of the "T".
Else, print a space.

Step 5 ]  

  printf("\n");

Moves the cursor to the next line after printing each row.



The Output of the Alphabet  T  star pattern 
Output 
C program to Print  Alphabet   T star pattern



 Summary

This program uses nested loops and conditionals to:
Print a full row of asterisks on the first row (a == 0)
Print a vertical column of asterisks in the middle (b == n/2) for all rows
Together, this forms a "T" shape.

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