Monday, June 18, 2012

To print the pattern


/* To print the pattern */

#include<stdio.h>

#include<conio.h>

void main()

{

  int i,j,k,m;

  clrscr();

  for(i=1;i<=5;i++)

  {

    for(j=1;j<=i;j++)

    {

      if((i+j)%2==0)

            printf("A");

      else

            printf("B");

    }

    printf("\n");

  }

  getch();

}

 

 

OUTPUT

 

A

BA

ABA

BABA

ABABA

 

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.