FLOYD’S TRIANGLE USING C



To write a c program to display the Floyd’s triangle using nested for loop. 

/*FLOYD’S TRIANGLE*/
#include<stdio.h>
#include<conio.h>
void main()
{
int n,s=0,i,j;
clrscr();
printf("Enter number of rows:");
scanf("%d",&n);
printf("\n\tFLOYD'S TRIANGLE");
for(i=0;i<=n;i++)
{
for(j=1;j<=i;j++)
{
s=s+1;
printf("\t%d",s);
}
printf("\n\n");
}
getch();
}









OUTPUT:
   Enter number of rows:4

        FLOYD'S TRIANGLE

        1

        2       3

        4       5       6

        7       8       9       10

Comments

Post a Comment

Popular posts from this blog

TRAVELING SALESMAN USING BRANCH AND BOUND TECHNIQUE

BOOKS DETAILS USING C STRUCTURE

TRAVELING SALESMAN USING BRANCH AND BOUND TECHNIQUE