Create Your First Functional Component in React JS – Beginner's Guide

Image
Create Your First Functional Component in React JS  1. Introduction When you start learning React JS, one of the first things you will come across is the concept of components. At first, components may seem like just another programming concept, but they are actually the foundation of almost every React application. Think about a website you use every day. It may have a header, navigation menu, login form, product section, and footer. Instead of writing all these elements together in one large file, React allows us to create separate parts and manage them independently. These separate parts are called components. In this tutorial, we are going to create our first functional component in React. We will start with a very simple example and gradually understand how components are created, exported, imported, and displayed on a webpage.  2. What Is a Functional Component in React?   A functional component is simply a JavaScript function that returns a user interface using JSX...

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

Popular posts from this blog

HTML Tag

CSS Text Color Explained with Syntax and HTML Examples

CSS Outline Offset Property with Practical Examples