3.05.2015

Floyd Algorithm Character Pattern In C

Q. WAP (Write A Program) to making the floyd algorithm character pattern in C as:

  A
  BC
  DEF
  GHIJ
  KLMNO

Ans.

/*c program for floyd algorithm character pattern*/
#include<stdio.h>
int main()
{

 int n=5,x='A';
 char r,c;
 for(r='A'; n>=1; r++, n--)
 {
   for(c='A'; c<=r; c++, x++)
       printf("%c", x);
   printf("\n");
 }
 getch();
 return 0;
}


/************************************************************
The output of above program would be:
*************************************************************/


Output of Floyd Algorithm Character Pattern In C
Figure: Screen shot for Floyd Algorithm Character Pattern In C

Your might also like:


      1
      2  3
      4  5  6
      7  8  9  10


      9
      8  7
      6  5  4
      3  2  1  0 
         

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


9 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. #include
    using namespace std;
    int main()
    {
    char c='A';
    for(int n = 1; n<=5;n++)
    {
    for(int i = 1; i<=n;i++,c++)
    {
    cout<<c;
    }
    cout<<"\n";
    }
    return 0;
    }

    ReplyDelete
  9. can anyone provide source code for,
    1
    2*3
    4*5*6
    7*8*9*10
    thanks in advance.

    ReplyDelete