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 display alphabet pattern I with asterisk

C program 

c program to display alphabet pattern I with asterisk



C program to Print  Alphabet  I star pattern 

Example 



#include <stdio.h>

int main() {
    int a, b;
    int n = 7;  
    // print of the I

    for (a = 0; a < n; a++) {
        for (b = 0; b < n; b++) {
           
            // Print * for the top, middle, and bottom rows
           
            // or the vertical column in the middle
           
            if (b == n / 2 || a == 0 || a == n - 1) {
                printf("*");
            }
            else
            {
                printf(" ");
            }
        }
        printf("\n");
    }

    return 0;
}


c program to display alphabet pattern I with asterisk
Explain Program

Step :1

#include <stdio.h>

standard input/output library for function printf() and scanf()

Step :2

int main() {

 Start of the main function where the execution begin

Step :3

    int a, b;

    int n = 7;

a and b are used as loop counters.

 n = 7 means the output  7x7 grid. 7 rows and 7 columns.

Step :4

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

 each row from a = 0 to a = 6 (total 7 iterations).

Step :5

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

Loops through each column for the current row.

b represents the current column number.

Step :6

            if (b == n / 2 || a == 0 || a == n - 1) {

                printf("*");

            } else {

                printf(" ");

            }

a == 0: This is the top row.

 a == n - 1 (which is 6): This is the bottom row.

 b == n / 2 (which is 3): This is the middle column.

Step :7

        printf("\n");

 printing all columns of a row, a new line is printed.

Step :8

    return 0;

C program to Print  Alphabet  I star pattern 

Output


C program to Print  Alphabet  I star pattern

Related Post :-

C program to print hollow full pyramid


Comments

Popular posts from this blog

HTML Tag

CSS Text Color Explained with Syntax and HTML Examples

HTML Input Type Submit Syntax and Example