1.18.2016

Reverse Floyd Triangle - Half Floyd Number Diamond

Q. Write a C Floyd triangle program in reverse order as following pattern:

     1
     2 3
     4 5 6
     7 8 9 10
     4 5 6
     2 3
     1

Ans.

/*c program of Reverse Floyd Triangle - Half Floyd Number Diamond*/

#include<stdio.h>
int main()
{
 int n=4,r,c,y,p=4,x=1;
 for(r=1; r<=n; r++)
 {
   for(c=1; c<=r; c++,x++)
       printf(" %d",x);
   printf("\n");
 }
 for(r=n-1; r>1; r--,p=p-2)
 {
   for(c=1,y=p; c<=r; c++,y++)
       printf(" %d",y);
   printf("\n");
 }
 printf(" 1");
 getch();
 return 0;
}


/***********************************************************
The output of above Reverse Floyd Triangle program would be:
***********************************************************/


Output of Reverse Floyd Triangle -  Half Floyd Number Diamond C program
Figure: Screen shot of Reverse Floyd Triangle -
Half Floyd Number Diamond C program


You might also like:



                       1
                   2 3
                  4 5 6
                 7 8 9 10

4. Reverse Floyd Number Pattern C program

             9
             8  7
             6  5  4
             3  2  1  0

5. Floyd Character Pattern C program:

               A
               B  C
               D  E  F
               G  H  I  J

                          1
                    1 1
                   1 2 1
                  1 3 3 1
                 1 4 6 4 1


2 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. how to print this pattern
    1
    3 2
    4 5 6
    10 9 8 7
    11 12 13 14 15
    can someone help me please

    ReplyDelete