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 Alphabet B Star Pattern with Example

                                              C Program



C program to Print B star pattern Asterisks pattern 

 Example:-


#include <stdio.h>

int main() {
    int a, b;
    int rows = 7;  

    for (a= 0; a < rows; a++) {
        for (b= 0; b < 5; b++) {
           
            if (b == 0 ||
                (a == 0 && b < 4) ||
                (a == rows / 2 && b < 4) ||
                (a == rows - 1 && b < 4) ||
                (b == 4 && a!= 0 && a != rows / 2 && a != rows - 1)) {
                printf("*");
            } else {
                printf(" ");
            }
        }
        printf("\n");
    }

    return 0;
}


This C Program Print a pattern in the shape of the capital letter B using asterisks "*"
Explain Program

Step :1

#include <stdio.h>

 standard input/output library for using functions like printf().

Step :2

int main() {

    int a, b;

    int rows = 7;

a and b are loop counters. 

rows = 7 sets the height of the pattern to 7 rows. This will determine how tall the printed "E" is.

Step :3

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

This loops control each row of the output.runs from a = 0 to a = 6
Step :4

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

This loops controls each row of the output. So it runs from a = 0 to a = 6
Step :5

        if (

            b == 0 ||

            (a == 0 && b < 4) ||

            (a == rows / 2 && b < 4) ||

            (a == rows - 1 && b < 4) ||

            (b == 4 && a != 0 && a != rows / 2 && a != rows - 1)

        ) {

            printf("*");

        } else {

            printf(" ");

        }

 b == 0s prints the left vertical line of the "E".

 (a == 0 && b < 4)

draws the top horizontal bar of the "E".

 (a == rows / 2 && b < 4)

 draws the middle horizontal bar.

(a == rows - 1 && b < 4)

 draws the bottom horizontal bar.

 (b == 4 && a != 0 && a != rows / 2 && a != rows - 1)

adds a small vertical extension on the top right.


C program to Print B star pattern Asterisks pattern 
OutPut :-
C program to Print B star pattern Asterisks pattern


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