React Component Nesting and Reusability Explained – A Beginner's Guide 2026

Image
1. Introduction to React Component Nesting and Reusability React JS is a popular JavaScript library used to create interactive and user-friendly web applications. One of the most useful concepts in React development is component-based architecture. Instead of writing an entire website inside one large file, developers divide the user interface into smaller and manageable parts called components. Two important concepts in this approach are component nesting and component reusability. Component nesting means placing one React component inside another component to build a complete user interface. For example, a website page may contain a header, navigation bar, sidebar, content section, and footer. Each section can be developed as a separate component and combined inside a main component. Component reusability means creating a component once and using it multiple times in different parts of an application. For example, the same button, product card, or navigation menu can be reused withou...

c program to display alphabet pattern G with asterisk

C Program pattern

C Program to Print Alphabet G Star Pattern with Example


C program to Print  Alphabet  G star pattern 
Example :-


#include <stdio.h>

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

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

    return 0;
}


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

Step :1

#include <stdio.h>

Includes the standard input-output library to use functions like printf().

Step :2

int main() { ... }

The entry point of the program.

Step :3

int a, b;

Variables a and b are loop counters:

  • a controls rows
  • b controls columns

Step :4

int n = 7;

 dimension of the pattern is 7 × 7.

Step :5

Outer Loops

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

loop goes from row 0 to 6 (7 rows in total).

Step :6

Inner Loop: 

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

inner loop  loop goes from column 0 to 6 

Step :7

First Condition

if ((a == 0 || a == n - 1) && b > 0 && b < n - 1)


  • When the current row is the first (0) or last (6) AND
  • column is not the first or last 
Step :8

Second Condition

else if ((b == 0 && a > 0 && a < n - 1))

  • Column is the first (0) AND
  • Row is between top and bottom (i.e., not row 0 or 6)

Step :9

🔹 Third Condition

else if ((a == n / 2 && b >= n / 2) || (a >= n / 2 && b == n - 1))

(a == n / 2 && b >= n / 2)

  • Row is the middle row 
  • Column is middle or to the right 

Step :10

(a >= n / 2 && b == n - 1)

  • From the middle row down 
  • At the last column

Step :11

 Else Condition

else

    printf(" ");

  • above conditions match, just print a space.

Final Line

printf("\n");

returen 0;

C program to Print  Alphabet  G star pattern 
Output :-

c program to display alphabet pattern G  with asterisk




Related Post :-

C program to print alphabet e star

Comments

Popular posts from this blog

CSS Text Color Explained with Syntax and HTML Examples

CSS Outline Offset Property with Practical Examples

Learn CSS text-decoration-color Property in Simple Words with Examples