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...

Write C Program to Print Right Half Character Pyramid Pattern

Write C Program to Print  Right Half Character Pyramid  Pattern


 Write C Program to Print Half Character Pyramid  Pattern 

Example 


#include<stdio.h>
int main ()

{

int i,j,n;
 printf("enter the no of line");
 
scanf("%d",&n);
 
for(i=1;i<=n;i++)
  {
 
for(j=1;j<=i;j++)
  {
 
printf("%c",(char)(i+64));
  }
 
printf("\n");
  }
   
getch();  

}


Write C Program to Print  Right Half Character Pyramid  Pattern 

Explain Program

Step :1

#include<stdio.h>

  • standard input/output library.
  •  use printf() and scanf() functions.

Step :2

int main()

  • use starting point of your program.

Step :3

. int i, j, n;

  • i – controls the row number
  • j – controls to the numbers of characters printed per row
  • n – stores the number of lines entered by the user

Step :4

printf("enter the no of line");

  •  user to enter the number of lines to print.

Step :5

scanf("%d", &n);

  • number of lines (rows) from the user and stores it in variable n.

Step :6

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

  • Outer loop: runs from 1 to n
  • Each iteration represents one row of the pattern.
Step :7

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

  • Inner loop: runs from 1 to i
  • It controls how many times a character is printed on each row.

Step :8

printf("%c", (char)(i + 64));

      This is the most interesting part!

  •  printing a character, not a number.

Step :9

 printf("\n");

  • After printing one row, move to the next line

 getch();

Write C Program to Print  Right Half Character Pyramid  Pattern  
 Program Output :

Write C Program to Print  Right Half Character Pyramid  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