c program for printing Right half pyramid pattern
Example
#include<stdio.h>
int main() {int i,j ,row;printf("enter the number of row");scanf("%d",&row);for(i=1; i<=row; i++) { for(j=1;j<=i;j++)
{printf("%d",i);}printf("\n"); }getch();}
c program for printing Right half pyramid pattern
Explain Program
Step :1
#include<stdio.h>
- Standard Input/Output library to use functions printf() and scanf().
Step :2
int main() {
- main function where your program starts execution.
Step :3
int i, j, row;
- Declares three integer variables:
- i and j for loop counters.
- row to store the number of rows entered by the user.
Step :4
printf("enter the number of row");
- user to enter how many rows they want in the pattern.
Step :5
scanf("%d", &row);
- input and stores it in the variable row.
Step :6
for (i = 1; i <= row; i++)
- Outer loop run from 1 .
Step :7
for (j = 1; j <= i; j++)
- Inner loop that run from 1 to i.
Step :8
printf ("%d", i);
- Print the current row number (i) in the same line.
Step :9
printf("\n");
- Moves the cursor next line after printing one row of numbers.
Step :10
getch();
No comments:
Post a Comment