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

C Program

C Program to Print Alphabet D Star Pattern with Example


C program to Print  Alphabet D star pattern 

Example

#include <stdio.h>

int main() {
    int i, j;
    int n = 7;

    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) {
           
            if (j == 0 ||
                (i == 0 && j < n - 1) ||
                (i == n - 1 && j < n - 1) ||
                (j == n - 1 && i != 0 && i != n - 1))
                printf("*");
            else
                printf(" ");
        }
        printf("\n");
    }
 
    return 0;
}


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

Step :1

#include <stdio.h>

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

Step :2

Main Function Start
int main() {

 Start of the main function where the execution begin

Step :3

Variable Declarations

int i, j;

int n = 7;

i and j are loop control variable

n = 7 specifies the size of the pattern: it will be 7 rows × 7 column.

Step :4

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

This loop control the row number (from 0 to 6).

 Run exactly 7 times because n = 7.

Step :5

Inner Loop 

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

loop control the column number within each row.

Step :6

if (j == 0 ||

    (i == 0 && j < n - 1) ||

    (i == n - 1 && j < n - 1) ||

    (j == n - 1 && i != 0 && i != n - 1))

    printf("*");

else

    printf(" ");

Step :7

else

    printf(" ");

If none of the above conditions are true, print a space.

Step :8

printf("\n");

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

Step :9

return 0;

C program to Print  Alphabet D star pattern 

Output

c program to display alphabet pattern D with asterisk

Related Post :-

swastik pattern c program

Comments