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

 C program pattern 

C Program to Print Alphabet J Star Pattern with Example


C program to Print  Alphabet  J star pattern 
Example 


#include <stdio.h>

int main()
{
    int a, b;
    int n = 7;
// Height of the J pattern

    for (a = 0; a < n; a++)
{
        for (b = 0; b < n; b++)
{
            // Print the vertical part of J
           
if (b == n / 2 && a != 0 ||
                (a == n - 1 && b <= n / 2) ||
                (a == n - 2 && b == 0))
                printf("*");
            else
                printf(" ");
        }
        printf("\n");
    }

    return 0;
}


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

Step :1

Header File

#include <stdio.h>

  •  Standard I/O library to use the printf function for output.

Step :2

.Main Function

int main()

entry point of any C program. Execution starts 

Step :3

Variable Declarations

int n = 7; // Height of the J pattern

  • a and b: Loop counters.
  • n = 7: The size of the square grid (7 rows × 7 columns). 

Step :4

Outer Loop – Row

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

  • Control the rows from a = 0 to a = 6 (7 rows in total).
Each loop iteration correspond to one line of output
Step :5

 Inner Loop – Columns

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

  • Control the columns from b = 0 to b = 6 
  • Prints either a * or a space " " for each cell.

Step :6

Main Logic – if Condition

if (b == n / 2 && a != 0 ||

    (a == n - 1 && b <= n / 2) ||

    (a == n - 2 && b == 0))

    printf("*");

else

    printf(" ");

analyze each part of this condition
Step :7

 Condition 1:

b == n / 2 && a != 0
  • n / 2 = 7 / 2 = 3 (integer division).
  • This checks:
  • Column 3 (b == 3)
  • For all rows except the first (a != 0)

 Draws the vertical bar of ‘J’, starting from row 1 down to 6 at the center.

Step :8

Condition 2:

a == n - 1 && b <= n / 2

  • a == 6 (bottom row)
  • b <= 3 → columns 0, 1, 2, 3

 bottom horizontal line of 'J'.

Step :9

Condition 3:

a == n - 2 && b == 0

  • a == 5 (second-last row)
  • b == 0 → first column

Add a small hook at the bottom left (curve of ‘J’)

Step :10

7. Line Break

printf("\n");

  • After finishing each row (b loop ends), moves to a new line for the next row 

. Return Statement

return 0;

C program to Print  Alphabet  J star pattern 
Output

C program to Print  Alphabet  J star pattern

Related Post :-


C program to print alphabet G 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