Header Ads

C Program to Display Floyd’s triangle


C Program to Display Floyd’s triangle

This C Program displays Floyd's triangle.
Here is source code of the C Program to display Floyd's triangle.The C program is successfully compiled and run on a Linux system. The program output is also shown below.



/*
* C Program to Display Floyd’s triangle
*/


#include<stdio.h>
int main( )
{

     int i, j, k = 1;
   printf("floyds triangle is\n");
  for( i = 1; k <= 20; ++i ) 

   {
     for( j = 1; j <= i; ++j )
       printf( "%d ", k++ );
       printf( "\n\n" ); 
   }
  return 0; 
}

Output:

floyds triangle is
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
16 17 18 19 20 21


Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

Powered by Blogger.