C program to print floyd's triangle


Following type of triangle is known as Floyd's triangle.

                             1
                             2 3
                             4 5 6
                             7 8 9 10

C Program to print Floyd's triangle

#include<stdio.h>

void main()
{
       int i,j,temp,n;
       clrscr();

       temp=1;
       printf("Enter the no. of rows : ");
       scanf("%d",&n);

       for(i=1;i<=5;i++)
       {
               for(j=i;j>=1;j--)
               {
                      printf(" %d",temp);
                      temp++;
               }
               printf("\n");
       }
       getch();
}


c program to print floyd's triangle


1 comments:

  1. nice example sir ..how to do the same using two variables or one for loop???thnks

    ReplyDelete
:) :)) ;(( :-) =)) ;( ;-( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ $-) (b) (f) x-) (k) (h) (c) cheer
Click to see the code!
To insert emoticon you must added at least one space before the code.