top of page
Writer's pictureanitadevkar

C Program to print Floyd's Triangle

Program:

#include <stdio.h>

int main()

{

int i,j,r,counter=1;

printf("Enter how many rows you want to print");

scanf("%d",&r);

for(i=1;i<=r;i++)

{

for(j=1;j<=i;j++)

{

printf("\t%d",counter);

counter++;

}

printf("\n");

}

return 0;

}

Output:

Enter how many rows you want to print 4

1

2 3

4 5 6

7 8 9 10

38 views0 comments

Recent Posts

See All

C Program for pyramid of number

Program: #include <stdio.h> int main() { int i,j; for(i=5;i>0;i--) //for rows { for(j=1;j<=i;j++) //for columns j loop will iterate...

Program to print Triangle

Program: #include <stdio.h> int main() { int i,j; for(i=5;i>0;i--) //for rows { for(j=0;j<i;j++) //for columns j loop will iterate...

Program to print triangle

In this program you will see working of nested for loop. Program: #include <stdio.h> int main() { int i,j; for(i=0;i<5;i++) //for...

Comments


bottom of page