C program and problem solution
Pages
Home
Array
Function
Puzzle
Overview
Write a C program to display a triangle of digits as follows. Number of rows is entered by keyboard
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
6 6 6 6 6 6
#include
<
stdio.h
>
int main
()
{
int
i, j, n;
printf(
"Enter the number of line:
"
);
scanf(
"%d"
,&n);
for
(i=1;i<=n;i++)
{
printf(
"\n"
);
for
(j=1;j<=i;j++)
printf(
"%3d"
,i);
}
return
0;
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment