C Program Print Right Half Pyramid pattern

c program


C Program  Print Right Half Pyramid pattern
C Program  Print Right Half Pyramid pattern

Examples :-     


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



C Program  Print Right Half Pyramid pattern

 Program Output 

Q.1] C Program  Print Right Half Pyramid pattern   Program Output

C Program  Print Right Half Pyramid pattern

Explain Program

Step 1 ]  

#include<conio.h>

 input/output  functions like printf() and scanf()

Step 2

int main()

 function, the entry point of your C program.

Step 3

int i, j, row;

Declares three integer variables 

i: outer loop counter (for rows) 

j: inner loop counter (for printing *) 

row: stores the number of rows entered by the user

Step 4

printf("enter the number");

 user to input the number of rows.

Step 5

scanf("%d", &row);

Takes input from the user and stores it in the row variable. 

%d is for reading an integer. 

&row means you're passing the address of the variable row to store the user input.

Step 6

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

This is the outer loop. 

It runs from 1 to the number entered by the user (row).

Step 7

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

This is the inner loop. 

For each row i, it prints i number of asterisks *.

Step 8

 printf("*");

Prints a single asterisk * without moving to the next line.

Step 9

printf("\n");

 moves the cursor to the next line.


Related Post :-

javascript assignment operators

PHP Program to print Alphabet Pattern


Comments

Popular posts from this blog

how to add background image in html.

HTML pre tag

How to insert image in html

Html anchor tag

Inline css in html