C Program Print Half Pyramid Using Numbers pattern

https://webdesigningtheory.blogspot.com/2025/03/c-program-to-print-inverted-half.html

C Program  Print Half Pyramid Using Numbers pattern

Example 


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

}


C Program  Print Half Pyramid Using Numbers pattern

Explain Program

Step :1

#include<stdio.h>

  • standard input-output header file use printf() and scanf().

Step :2

void main()

  • main function  execution starts.

Step :3

 Variable Declarations

int i, j, r;

  • r: Number of rows for the pattern (user input).
  • i: Controls the outer loop (rows).
  • j: Controls the inner loop (columns/numbers in each row).

Step :4

printf("enter the number");

scanf("%d", &r);

  •  user to enter the number of rows.

Step :5

Outer Loop – Controls the Rows

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

  • Starts 1 and goes up to r.
  • Each iteration print one row of the triangle.

Step :6

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

{

    printf("%d", j);

}

  •  each row i, it prints numbers from 1 to i.

Step :7

printf("\n");

cursor to the next line

Step :8

return 0;

C Program Print Half Pyramid Using Numbers pattern

 Program Output :- 



Number Pattern Program in C


Related Post :-

C Program Print Right Half Number Pyramid Pattern

C Program Print Righ Half Character Pyramid Pattern

c program print square star 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