Search This Blog

Loading...

Sunday, March 29, 2015

Two Patterns using BlueJ Program


Two patterns as given below will be printed using BlueJ program.
The patterns are:

e
ed
edc
edcb
edcba

and

a c e g
i k m
o q
s

First pattern program.

class A
{
 public void showPattern()
 {
 int i,j,x;
 for(i=0;i<=4;i++)
 {
  x=101;
  for(j=0;j<=i;j++)
  {
  System.out.print((char)x);
  x--;
  }
  System.out.println();
  }
  }
   public static void main(String args[])
  {
   A ob=new A();
   ob.showPattern();
   }
   }

   Second pattern program


class A
{
 public void showPattern()
 {
 int i,j,x=97;
 for(i=0;i<=3;i++)
 {
  
  for(j=i;j<=3;j++)
  {
  System.out.print((char)x);
  x=x+2;
  }
  System.out.println();
  }
  }
   public static void main(String args[])
  {
   A ob=new A();
   ob.showPattern();
   }
   }

Thursday, March 5, 2015

C Program on entering password


In this C language program, user will enter any word or sentence and the entered word or sentence will be treated as a password. Entered characters will be echoed as ‘*’ and finally the password will be displayed.



#include < stdio.h >
void main()
{
 char ch[100];
 int i=0;
 int x;
 clrscr();
      printf("\nEnter Password:");
 while(1)
 {
 x=getch();
 printf("*");
  if(x==13)
   break;
   ch[i]=(char)x;
   i++;
   }
   printf("\nEntered password is=%s",ch);
   getch();

   }

CHECK HERE FOR PREVIOUS POSTS

Google+ Followers

Subscribe via email

Enter your email address:

Delivered by FeedBurner