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 print Inverted Right Half Pyramid Star Pattern

C Program print Inverted Right Half Pyramid  Star Pattern



C Program print Inverted Right Half Pyramid  Star Pattern

Example :- 


//inverted half pyramidoc c language


#include<stdio.h>
int main()
{
int i,j,row;
printf
("enter number row");
scanf("%d",&row);
for(i=row;i>=1;i--)
{
for
(j=1;j<=i;j++)
{
printf
("*");
}
printf
("\n");
}
getch
();
}


C Program print Inverted Right Half Pyramid  Star Pattern
Explain Program

Step :1

#include<stdio.h>

  • Standard Input Output header file.
  • Functions like printf() and scanf() are defined in stdio.h.

Step :2

int main()

  • main function

Step :3

int i, j, row;

  • Declares three integer variables:
  • row: stores the number of rows of the triangle (user input).
  • i and j: loop control variables used in for loops.

Step :4

printf("enter number row");
  •  user to enter the number of rows.

Step :5

scanf("%d",&row);

  •  input, stores to  the variable row.
  • %d tells the compiler you're expecting an integer

Step :6

for(i=row; i>=1; i--)

  • outer loop which run from row downs to 1.
  • It control the number of line (or rows) to print.

Step :7

for(j=1; j<=i; j++)

  • This is the inner loop which prints the asterisks * in each row.
  • On each line, the number of asterisks equals the current value of i.

Step :8

printf("*");

  • Prints one asterisk without a newline.

Step :9

printf("\n");

  •  prints a newline to move to the next row.

getch();


C Program print Inverted Right Half Pyramid  Star Pattern

Program Output :-

C Program print Inverted Right Half Pyramid  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