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 E with asterisk

  C program

c program to display alphabet pattern E with asterisk



C program to Print  Alphabet E star pattern 
Example


#include <stdio.h>

int main() {
    int a,b;
    int height = 7;
    int width = 5;  

    for (a = 0; a < height;a++) {
        for (b = 0; b < width; b++) {
           
            if (b == 0 || (a == 0 || a == height / 2 || a == height - 1))

          printf("*");

        else

          printf(" ");

        }

        printf("\n");
   
}

    return 0;

}


c program to display alphabet pattern E 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 height = 7;

    int width = 5;

a and b are loop counters.

 height and width define the size of the pattern.

 height = 7: Number of rows.

 width = 5: Number of columns.

Step :4

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

outer loop run  a = 0 to a = 6 (7 iterations), controlling the rows

Step :5

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

 inner loops run b = 0 to b = 4 (5 iterations), control the column (characters in each row).

Step :6

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

                printf("*");

            else

                printf(" ");

This condition determines where to print * or a space. 

Step :7

b == 0

prints a vertical line of * in the first column — like the vertical bar of "E".

 a == 0

Top row — prints the top horizontal line.

  a == height / 2

Middle row — prints the middle horizontal line.

  a == height - 1

Bottom row — prints the bottom horizontal line.

Step :8

printf("\n");

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

Step :9

return 0;

C program to Print  Alphabet E star pattern  
Output 
C program to Print  Alphabet E star 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