BlueJ Tutorial

BlueJ Tutorial


Pattern on characters using BlueJ and C Language

Posted: 03 Dec 2012 09:45 PM PST





Here is a pattern given below and the pattern will be displayed using both BlueJ and C Language.



ABCDE
BCDE
CDE
DE
E
f
fg
fgh
fghi
fghij


BlueJ program of the pattern

class archisman
{
 int i,j,n=5;
 char ch;
 public void show()
 {
      for(i=0;i<10 i="i" span="span">
      {
        if(i<5 span="span">
        {
            ch='A';
        ch=(char)(ch+i);
    }
    else
    ch='f';
             
           for(j=0;j
           {
                System.out.print(ch);
        ch=(char)(ch+1);
                }
              if(i>=5)
              n++;
              else if(i<4 span="span">
              n--;
            System.out.println();
        }
    }
}


Same program using c language

#include
void main()
{
 int i,j,n=5;
 char ch;
 clrscr();
     for(i=0;i<10 i="i" span="span">
      {
            if(i<5 span="span">
            {
                ch='A';
            ch=ch+i;
    }
    else
    ch='f';

               for(j=0;j
               {
                   printf("%c",ch);
            ch=ch+1;
                        }
                  if(i>=5)
                  n++;
                  else if(i<4 span="span">
                  n--;
               printf("\n");

    }
getch();
}



Post a Comment