OUESTION:- print a pattern as shown below
1
2 2
3 3 3
4 4 4 4
#include <stdio.h>
#include <conio.h>
int main()
{
int i, j, k, no;
printf("Enetr a value: ");
scanf("%d", &no);
// rows
for (i = 1; i <= no; i++)
{
// space
for (j = no; j >= i; j--)
{
printf(" ");
}
// display
for (k = 1; k <= i; k++)
{
printf("%d ", i);
}
printf("\n");
}
return 0;
getch();
}
Note:- you can make changes to all the patterns according to your wants and need.
OUTPUT
Enetr a value: 5
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
Follow our page for regular updates.
0 Comments