Floyd’s triangle in C.

 

01 #include <stdio.h>
02
03 int main()
04 {
05 int n,i,c,a = 1;
06 printf("Enter the number of rows of Floyd's triangle to print:n");
07 scanf("%d",&n);
08
09 for (i = 1; i <= n; i++)
10 {
11 for (c = 1; c <= i; c++)
12 {
13 printf("%d ",a);
14 a++;
15 }
16 printf("n");
17 }
18
19 return 0;
20 }
 
 OUTPUT :

Enter the number of rows of Floyd's triangle to print:
4

1
2 3
4 5 6
7 8 9 10

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *