Program to generate Floyd's triangle
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int r, i, j, c = 1;
clrscr();
printf("Enter the number of rows : ");
scanf("%d", &r) ;
printf("\nFloyd's triangle is : \n\n");
for(i = 0 ; i < r ; i++)
{
for(j = 0 ; j <= i ; j++)
{
printf("%-6d", c);
c++;
}
printf("\n\n");
}
getch();
}
Output:
Enter the number of rows : 5
Floyd's triangle is :
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
-
UpdatedDec 30, 2019
-
Views5,263
You May Like
Program to maintain employee details using structures
Program to maintain student details using structures
Check whether the person is eligible to vote or not
Print the numbers that are divisible by a given no.
Program to generate magic square
To sort the given numbers in ascending & descending order