Sunday 28 February 2016

Floyd Algorithm Character Pattern In C

Q.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;

}

No comments:

Post a Comment

Ads Inside Post