QUESTION:- Write a program in C to display the pattern like a right angle triangle with a number.
The pattern like :
1
22
333
4444
program
#include <stdio.h>
#include <conio.h>
void main()
{
int a;
printf("enter a value of a: ");
scanf("%d", &a);
// row
for (int i = 1; i <= a; i++) // 1 1 1 1 1
{
// column
for (int j = 1; j <= i; j++)
{
printf("%d", i); // 1 2 3 4 5
}
printf("\n");
}
}
enter a value of a: 5
1
22
333
4444
55555
Follow our page for regular updates.
0 Comments