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

C Program

C Program to Print Alphabet C Star Pattern with Example


 C program to Print  Alphabet C star pattern 
Example


#include <stdio.h>

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


    for (a = 0; a < rows; a++)
{
        for (b = 0; b < rows;b++)
{
         
            if (a == 0 || a == rows - 1 || b == 0)
{
             
                if ((a == 0 || a == rows - 1) && b > 4)
                    continue;
                printf("*");
           
} else {

                printf(" ");
            }
        }

        printf("\n");
    }

    return 0;

}


C Program to Print Alphabet C Star Pattern with Example
Explain Program

Step :1

#include <stdio.h>

 standard input-output library in C, so you can use printf().

Step :2

int main() {

    int a, b;

    int rows = 7;

a and b are loop counters use for iterating through row and columns, respectively.

Step :3

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

This loop controls the vertical position (top to bottom).

Step :4

Inner Loop: 

Controls Columns

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

Controls the horizontal position in each row (left to right).

Step :5

Main Logic for Pattern Drawing

if (a == 0 || a == rows - 1 || b == 0)

condition determines when to print a *:

 a == 0 → Top row (first row)

a == rows - 1 → Bottom row (last row)

 b == 0 → Leftmost column

Step :6

Inner Condition: continue

if ((a == 0 || a == rows - 1) && b > 4)

 top or bottom row, column > 4, then:

Step :7

Space

printf("*");

Print a star if the condition.

Step :8

else {

    printf(" ");

}

condition are not met, print to  the  space.

  printf("\n");

 printing one row,next line.


C program to Print  Alphabet C star pattern 
Output
C program to Print  Alphabet C star pattern


Related Post :-

C Program print Inverted Right Half Pyramid Star Patern

Comments

Popular posts from this blog

HTML Tag

CSS Text Color Explained with Syntax and HTML Examples

HTML Input Type Submit Syntax and Example