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 display alphabet pattern E with asterisk

  C program

c program to display alphabet pattern E with asterisk



C program to Print  Alphabet E star pattern 
Example


#include <stdio.h>

int main() {
    int a,b;
    int height = 7;
    int width = 5;  

    for (a = 0; a < height;a++) {
        for (b = 0; b < width; b++) {
           
            if (b == 0 || (a == 0 || a == height / 2 || a == height - 1))

          printf("*");

        else

          printf(" ");

        }

        printf("\n");
   
}

    return 0;

}


c program to display alphabet pattern E with asterisk
Explain Program

Step :1

#include <stdio.h>

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

Step :2

int main() {

 Start of the main function where the execution begin

Step :3

    int a, b;

    int height = 7;

    int width = 5;

a and b are loop counters.

 height and width define the size of the pattern.

 height = 7: Number of rows.

 width = 5: Number of columns.

Step :4

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

outer loop run  a = 0 to a = 6 (7 iterations), controlling the rows

Step :5

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

 inner loops run b = 0 to b = 4 (5 iterations), control the column (characters in each row).

Step :6

            if (b == 0 || (a == 0 || a == height / 2 || a == height - 1))

                printf("*");

            else

                printf(" ");

This condition determines where to print * or a space. 

Step :7

b == 0

prints a vertical line of * in the first column — like the vertical bar of "E".

 a == 0

Top row — prints the top horizontal line.

  a == height / 2

Middle row — prints the middle horizontal line.

  a == height - 1

Bottom row — prints the bottom horizontal line.

Step :8

printf("\n");

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

Step :9

return 0;

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

Related Post :-

Comments

Popular posts from this blog

HTML Tag

CSS Text Color Explained with Syntax and HTML Examples

CSS Outline Offset Property with Practical Examples