Friday 21 September 2012

RollOver Feature on an Image in your website

Rollover is a feature in this effect when you move mouse on a
image then image change on that button instantly.This is possible with the help combination
of java script and css using inline mode



     <img src=a1.jpg height=100px width=100px
        onmouseover="this.src='a2.jpg'"
        onmouseout="this.src='a1.jpg'" />

   <img src=a1.jpg height=100px width=100px
        onmouseover="this.src='a2.jpg';this.style.border='outset 5px blue'"
        onmouseout="this.src='a1.jpg';this.style.border=''" />
     

RollOver and RollOut Effect on Button in a Website


<input type="button" value=" Girfa : Student Help " id="b1"    
      onmouseover="this.style.fontWeight='bold';"
      onmouseout="this.style.fontWeight='normal'";
      />


<input type="button" value=" Girfa : Student Help " id="b1"
      style="background-color:'blue'"
      onmouseover="this.style.backgroundColor='aqua';"
      onmouseout="this.style.backgroundColor='blue'";
      />



<input type="button" value="Girfa : Student Help"
      onmouseover="this.style.color='Blue';this.style.backgroundColor='yellow';this.style.border='outset 3px red'"
      onmouseout="this.style.color='';this.style.backgroundColor='';this.style.border=''" />


DLL in VB 6.0,VB.Net,C#

Hi......
DLL statds for Dynamic Link Library which comprise Business logic .At A huge level of 
Software development it is suitable to implement business login separately. 
DLL provides facility of reversibility means  ones you have been created a DLL 
for a task then many project can use your DLL, Like if you have a DLL of
Calculator logic then many Application can use it after importing DLL ij their project...

DLL in VB 6.0
  • Open VB 6.0 and select ActiveXdll
  • Change your final project name as you're going to make otherwise you may be face problem of name contradiction because default name of dll project is Project 1 and VB Standard exe has also same so change name of dll project or standard exe project
  • On Project explorer window change of class1 as your requirement
  • now make some procedure and function of your logic as showing in following picture
  • Save DLL project
  • For make DLL select File > Make Project1 DLL...
  • Now your DLL is ready to use
Develop by Raj Kumar

How to use This DLL
  • Open VB 6.0
  • Select Standard EXE
  • For add a DLL in your project ..
  • Go to Project > Refereneces.
  • Browse Your DLL File and click open
  • Now you can use DLL class
  • Make an object of class which you have made in your DLL project
  • Call function of your DLL class using . operator
After import DLL you can use it at anywhere here is code which you can use on a button click event

Private Sub Command1_Click()
    Dim ob As New Class1
    ob.Show
    
End Sub

Private Sub Command2_Click()
    Dim ob As New Class1
    MsgBox (ob.Sum(10, 20))
End Sub
DLL in C# and VB.Net

  • Open Visual studio 2008 File > Project > Select class library form template
  • Implement your function and logic inside class body
  • After implementing logic press f6 for build your DLL Project
  • For use a DLL in windows Application right click of root folder from solution explorer
  • Add References..
  • Browse your project DLL
  • Now make an object of class which you have named in DLL file
Code of DLL my DLL file

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ClassLibrary1
{
    public class Class1
    {
        public int sum(int a,int b)
        {
            return a + b;
        }
    }
}

Thursday 20 September 2012

Zig Zag Effect on text and image using MARQUEE


Marquee is a  HTML tag which is use scroll object inseide it.
You can scroll any thing in body of marquee. Marquee tag has property direction which moves
and object(left,right,up,down) , Behavior property change behavior of scrolling.....
You can put image instead of <h1> or any thing which you want to move in a zigzag way... Enjoy marquee.

Girfa : Student Help

<marquee behavior=alternate>
        <marquee direction=down behavior=alternate>
            <marquee direction=up behavior=alternate>
                <h1>Girfa : Student Help</h1>
            </marquee>
        </marquee>       
   </marquee>

Database connectivity with MS Access in VB 6.0


Database connection with VB 6.0
VB provides a rich set of of database connectivety.Most of work which is needed done by aotomatically.There’re some control which provides database connectivety.Here i’m going to implement it using ADODB.
ADODB provides connection class.which handle insert ADODB,update,delete operation efficiently.
Ø       Make an objet of ADODB,Connection
Ø       Then call open function which takes connection string as argument
Ø       Connection string comprise database enzine name and your database path.I have supply relative path my database is in current folder.


Maked by Raj kumar

Controls :
    ( Three label,,Three Moniter,Three  textbox )

Coding

Dim con As New ADODB.Connection

Private Sub btnDelete_Click()
    If txtRoll.Text = "" Then
        MsgBox "Please enter roll no."
        txtRoll.SetFocus
    Else
        If MsgBox("Are you sure to delete this record", vbYesNo, "Girfa") = vbYes Then
            con.BeginTrans
            con.Execute "delete from stu where roll=" & txtRoll.Text
            con.CommitTrans
            txtRoll.Text = ""
            MsgBox "Record deleted"
        End If
        
    End If
End Sub

Private Sub btnSave_Click()
    If txtRoll.Text = "" Or txtName.Text = "" Or txtCity.Text = "" Then
        MsgBox "Please Fill alll field"
    Else
        con.BeginTrans
        con.Execute "insert into stu values(" & txtRoll.Text & ",'" & txtName.Text & "','" & txtCity.Text & "')"
        con.CommitTrans
        MsgBox "Saved", , "Girfa"
        
    End If
End Sub

Private Sub btnUpdate_Click()
    If txtRoll.Text = "" Or txtName.Text = "" Or txtCity.Text = "" Then
        MsgBox "Please enter all field value"
    Else
        con.BeginTrans
        con.Execute "update stu set name='" & txtName.Text & "',city='" & txtCity.Text & "' where roll=" & txtRoll.Text
        con.CommitTrans
        MsgBox "Record has been updated", , "Girfa"
    End If
End Sub

Private Sub Form_Load()
    con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=bsw.mdb;Persist Security Info=False"
End Sub



Wednesday 19 September 2012

How to Print New Line in VB 6.0 Message Box


Message box is form which is use to print a message
by default its print text in same line
but you print your text in new line...... howz????
take a look..........
Private Sub Command1_Click()
    MsgBox "    Girfa " & vbCrLf & "Student Help", , "Girfa"
End Sub


Timer Using Java Script


We use timer control in VB6.0 ,VB.Net's window application.You can implement it in your web page using
java script.

Setting a timeout is done using the window’s setTimeout() method. This method accepts two arguments:
the code to execute and the number of milliseconds (1/1000 of a second) to wait before executing it. The
first argument can either be a string of code (as would be used with the eval() function) or a pointer to a
function. For example, both these lines display an alert after one second:



When you call setTimeout(), it creates a numeric timeout ID, which is similar to a process ID in an
operating system. The timeout ID is essentially an identifier for the delayed process should you decide,
after calling setTimeout(), that the code shouldn’t be executed. To cancel a pending timeout, use the
clearTimeout() method and pass in the timeout ID:



<html >
<head >
    <title>Girfa Timer Demo</title>
    <script language=javascript>
        var i=0;
        var id;
        function sstart()
        {
            var ob=document.getElementById('s1');
            i++;
            ob.innerHTML=i;
            id=setTimeout("sstart()",1000);          
        }
        function tstop()
        {
         
          clearTimeout(id);
         
        }
        function tstart()
        {
            setTimeout("sstart()",1000);
        }
    </script>
 
</head>
<body onload="sstart()">
    <form>
             <span id="s1" style="font-size:x-large">0:0:0</span>
            <input type=button value="start" onclick="tstart()" />
            <input type=button value="stop" onclick="tstop()" />
    </form>
</body>
</html>




Modal Question and Programming C Language

Practical Question paper of C Language

Loop


Miscellaneous

One Dimension Practical model question paper

Q 1. Write a  program to shift array element with previous one (Left-Sifting) . Last element will replace with first element ?

Q 2. Write a program to count even and odd number in an array?

Q 3.Write a program to make three array name mArry, even & odd move array value in even & odd array respect to this type ?

Q 4.Write a program to find smallest and highest number from an array?

Q 5. Write a program to print an array in reverse order?

Q 6. Write a program to print only consecutive number of an array?

Q 7. Write a program to implement union and intersection?

Q 8. Write a program to merge two array into a single array?

Q 9.Write a program to spilt an array into two equal parts ?

Q 10. Write a program to input Fibonacci into array?

Q 11.Write a program to find out prime number between given range and saved these number into array. Range should be up-to 1 to 10000 ?

Q 12.Write a program to input 10 numbers and print each element with multiply by its equivalent index position?

Q 13. Write a program to print an array value without using loop ?

Q 14.Write a program search a number in array ?

Q 15.Write a program to print an array value skip by one index?

Q 17. Write a program to input ASCII value and print its equivalent character.Using 7 bit ASCII/

One Dimension Character Array  Programs

1. Write a program to count Vowels and consonant?

2. Write a program to count no. of word in an array?

3. Write a program to convert lower case character into upper case

4. Write a program to print only consecutive appeared character

5. Write a program to implement concatenation?

6.  Write a program to implement substring function type functionality without using library function.

7. Write a program to input small letter if capital letter is there ignore that

8. Write a program accept any case input and convert it small case

9. Write a program input character only and display error message on any other input?

10. Write a program to search a substring and print its index

11. Write a program to search a word and reverse that

12. Write a program implement encryption i.e. change each character to two character forward. i.e.   A-> C,B->E

13. Write a program to implement following format
              G                                              GIRFA
              GI                                             GIRF
              GIR                                          GIR
              GIRF                                        GI
              GIRFA                                     G

14. Write a program to implement abbreviation i.e.
Input : Ashok Kumar Yadav
Output : A.K. Yadav

15. Write a program to implement find and replace all functionality

16. Write a program to check whether a string is palindrome or  not

17. Write a program reverse a string

18. Write a program to reverse each word into array

19. Write a program to input string password. i.e.(A Small and Capital character , A number and a special symbol)

20. Write a program to check validity of an email address. (an email can have only one @ symbol after that . is required and no space is allowed)

21. Write a program count frequency of each character individually.
22. Write a program to convert number to word?
   i.e.    123
            One Hundred Three Only


Prime Number

#include<stdio.h>
void main()
{
int i,j,k;
printf("Enter number>> ");
scanf("%d",&i);
j=2;
while(j<i)
{
if(i%j==0)
break;
j++;
}
if(i==j)
printf("Prime");
else
printf("Not Prime");
}

Reverse A number

#include<stdio.h>
void main()
{
int i,j,k,m=0;
printf("Enter number>> ");
scanf("%d",&i);
k=i;
while(i>0)
{
j=i%10;
i=i/10;
m=m*10+j;

}
printf("Reverse number is %d",m);
}
Armstrong Number

void main()
{
int i,j,k,m=0;
printf("Enter number>> ");
scanf("%d",&i);
k=i;
while(i>0)
{
j=i%10;
i=i/10;
m=m+j*j*j;

}
if(k==m)
printf("\nArmstrong");
else
printf("\nNot Armstrong");
}

Fibonacci Series


#include<stdio.h>
void main()
{
   int a,b,c;
  c=1;
  a=0;
  b=0;
   while(c<200)
   {
   a=b;
   b=c;
  c=a+b;
  printf("%d\t",a);
   }
}

Factorial number using Recursive function

       #include<stdio.h>
       int fact(int n)
      {
   if(n==0)
  return(1);
   else
  return(n*fact(n-1));
      }
      void main()
     {
    int a;
    printf("enter a number>> ");
    scanf("%d",&a);
    printf("\n\tFactorial=%d",fact(a));
    }
Print your name without using semicolon

     #include<stdio.h>
     void main()
    {
       if(printf("Hello Girfa"))
          {
          }
    }

Palindrome

A palindrome is a word, phrase, number, or other sequence of units that may be read the same way in either direction, with general allowances for adjustments to punctuation and word dividers.

/* Without Using Library function */
void main()
{
    char nm1[20],nm2[20];
    int i,j;
    printf("Enter your text>> ");
    gets(nm1);
       for(i=0;nm1[i]!='\0';i++);
    /* Assine first string in second in reverse order */
      for(i--,j=0;i>=0;i--,j++)
        nm2[j]=nm1[i];

    /* Checking whether both're same or not */
       for(i=0;nm1[i]!='\0';i++);
    for(j=0;nm1[j]==nm2[j] && nm1[j]!='\0';j++);
    if(j==i)
        printf("Palindrom");
    else
        printf("Not Palindrom");
}

/* Using Library String.h function
void main()
{
    char nm1[20],nm2[20];
    int i,j;
    printf("Enter your text>> ");
    gets(nm1);
    strcpy(nm2,nm1);
    strrev(nm2);
    if(strcmp(nm1,nm2)==0)
        printf("Palindrom");
    else
        printf("Not Palindrom");
  }

Multiplication of 2D Array (Matrix)

#include<stdio.h>
#define row 2
#define col 2
void main()
{
/* *********Multiplication Rule ***********
  First Arrar Column must be same as Second Array row
  otherwise multiplication can't take place
  By Girfa
*/
int a[row][col],b[row][col],cc[row][col],r,c,k,sum=0;
clrscr();
printf("\n*****Enter Data for first Array*****\n");
for(r=0;r<2;r++)
{
for(c=0;c<2;c++)
{
printf("Enter [%d][%d]'st number>>  ",r+1,c+1);
scanf("%d",&a[r][c]);
}
}
printf("\n*****Enter Data for Second Array*****\n");
for(r=0;r<2;r++)
{
for(c=0;c<2;c++)
{
printf("Enter [%d][%d]'st number>>  ",r+1,c+1);
scanf("%d",&b[r][c]);
}
}
for(r=0;r<2;r++)
{
for(c=0;c<2;c++)
{
cc[r][c]=0;
}
}
for(r=0;r<2;r++)
{
for(c=0;c<2;c++)
{

  for(k=0;k<2;k++)
  {
sum=sum+a[r][k]*b[k][c];
  }
  cc[r][c]=sum;
  sum=0;
}
}
clrscr();
printf("\n***** first Array*****\n");
for(r=0;r<2;r++)
{
for(c=0;c<2;c++)
{
printf("\t%d",a[r][c]);
}
printf("\n");
}
printf("\n***** Second Array*****\n");
for(r=0;r<2;r++)
{
for(c=0;c<2;c++)
{
printf("\t%d",b[r][c]);
}
printf("\n");
}
printf("\n***** Result *****\n");
for(r=0;r<2;r++)
{
for(c=0;c<2;c++)
{
printf("\t%d",cc[r][c]);
}
printf("\n");
}
getch();

Tuesday 18 September 2012

How to connect word document to MS Access database

HI............
word is a software which is used to process word but you can save record in access.
Using word for doing this you will have to use control box from Toolbar.
After getting control box, Take control which you want...
I'm using 3 textbox and 1 button in my example




Now double click on your button . VB coding window will appeared.
For database connectivity I have use ADODB class.
you need to  add   a reference of  this class otherwise you can't use this.
for add reference in vb coding window click
Tools>references
Select Microsoft ActiveX Data Object 2.6 Library

Start and Stop Marquee using mouseover and mouseout event and News Ticker

Hi.... this is raj..........
Marquee is a HTML tag which is use to scroll an object over a page.
There are many direction (left,right,alternate). Where object moves.You can stop
and start a marquee using java script.Marquee object has methods start and stop.
Which are respectively used to start and stop a marquee.
Copy and paste following example save with .htm or .html extention...


<html>
<head>
<title>Girfa : Java Script Marquee Demo </title>
<script language="javascript">
function stopM()
{
var ob=document.getElementById('m1');
ob.stop();
}
function startM()
{
var ob=document.getElementById('m1');
ob.start();
}
</script>
</head>

<body>
<div style="height:210px;width:210px;border:outset 3px blue"">
<marquee onmouseover="stopM()" id="m1"
onmouseout="startM()" >
<a href="a.jpg"><img src="a.jpg" height=200px width="200px">
<a href="b.jpg"><img src="b.jpg" height=200px width="200px">
</marquee>
</div>
</body>
</html>


Monday 17 September 2012

How to stop multiline textbox resizing

Multi line textbox is a form control .where user can enter multiple line of text.
We can specify the size of textbox but user can change it run time using mouse
if you want to stop it paste following css in your text box HTML tag

style="resize: none;"


<textarea  rows="2" cols="20"

style="height:96px;width:185px;resize: none;"></textarea>

Create Keyboard Shortcuts to Insert Symbols in Word and Excel

Hi......
Office has many symbol which is not available in keyboard but we write them using symbol 
Let’s start with Word
, which is the easiest. In Word 2003, press InsertSymbol, which engages the Symbol screen (see screenshot below). In Word 2007, press Insert on the Ribbon and then click on SymbolMore Symbols.

Develop by Raj Kumar

Develop By Raj Kumar

Be careful when you are going to use a key click in shortcut textbox under circle press key which you which
you want to use. You can't type in shortcut key  text box click assine.

Excel

In Excel 2003, press Tools and select the AutoCorrect Options. In Excel 2007, click the Office button and Excel Options. Then click on Proofing on the left of the dialog box and click on AutoCorrect Options.

Develop by Raj Kumar





Handle more than one button event in java

In computer science an event is an action that is usually initiated outside the scope of a program and that is handled by a piece of code inside the program. GUI based programming is based on event, if you want handle event of a button in java (Applet,Swing) then you have to use ActionListener interface and implements actionPerformed funtion.We use more than one button in java program for handle each button event individually for achieve this we mustidentified each button event uniquely. You can identified button by its name or its text value, text value is not good becouse there can be same text on more than one button. Getting Button name is more usefull conside following program.....
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class ButtonEventDemo extends Applet implements ActionListener
{  
       Button bt1,bt2,bt3;   Label lbl;  
       public void init() 
       {     
            bt1=new Button("Button1");   
            bt2=new Button("Button2");
            bt3=new Button("Button3");     
           lbl=new Label("Label");    
           Add(bt1);        Add(bt2);      
           Add(bt3);        Add(lbl);      
           bt1.addActionListener(this);     
           bt2.addActionListener(this);        
           bt3.addActionListener(this);  
      } 
      public void actionPerformed(ActionEvent e)
      {     
           // String s=e.getActionCommand();       
          // if(s=="Button1")     
          //  {      
         //             lbl.setText("Clicked Button 1");   
         //   }       
         //   else     
         //   {      
         //             lbl.setText("Clicked Button 2");     
        //    }         
             Object ob=e.getsource();           
             if(ob.equals(bt1)                
                 lbl.setText("Clicked Button 1");      
             else          
             {                
                   if(ob.equals(bt2)                   
                      lbl.setText("Clicked Button 2");                 
                  else                       
                       lbl.setText("Clicked Button 3");           
              }
         }

                  
String s=e.getActionCommand();
this command will set text of control which create control in s e.g.  if button clicked then s will hold Button1 textso we can check control text to uniquely identified a control but its not so good because there can be same text of more than one control.                 
                Object ob=e.getsource();
this line initialize ob with Button reference which name is bt1 if bt1 is clicked otherwise other control instanceso it is useful  to uniquely identified button because button name always unique in a program . 

Saturday 15 September 2012

Make your own list in excel 2003 and 2007

Excel has a powerful feature which enable user to input by using drag operation we have use this when we want to write month name we'll just have to write jan or January and drag it excel will automatically fill all remaining month name.
You can make your own custom list which help you to input in a fast way....


Excel 2003     

  • Type your list as in the image
  • Goto tools >Optoins>CustomLists>Select your list range>import

Excel 2007     

  • Type your list as in the image
  • Office Button > Excel Options > Popular > Edit Custom List.. > Select your list range > import

Friday 14 September 2012

How to create mirrored text in PowerPoint, in Word, and in Excel


A mirror image is a reflected duplication of an object that appears identical but reversed. As an optical effect it results from reflection
To create mirrored text with WordArt, follow these steps:
On the Drawing toolbar, click Insert WordArt.
Enter your Text which you want to make Rotate and make its Copy as in image...





  •  Now click on Upper In charge word art
  •  Click format
  • Then click rotate and select Flip Vertical

Friday 31 August 2012

Don't Do it

This program will act as virus because it stop your computer working until you  restart your computer.This is power of DOS batch file
  1. start
  2. start.bat
Save this file with start.bat name and run...
and give me your feedback I'm waiting

Tuesday 28 August 2012

Java Package


Hi there......
Java provides a mechanism for partitioning the class name space into more manageable chunks. This mechanism is the package. The package is both a naming and a visibility control mechanism. You can define classes inside a package that are not accessible by code outside that package.
To create a package is quite easy: simply include a package command as the first
statement in a Java source file. Any classes declared within that file will belong to the
specified package. The package statement defines a name space in which classes are
stored. If you omit the package statement, the class names are put into the default
package, which has no name.
  • Package name must be saved in same name folder
  • One package can comprise more than one class
  • Java source code and class should be saved in same folder as package name
  • One Java source file can include only one public class
  • For make more than one class in same package every java source file must be saved in separate file
  •  Java source file class should be public visibility otherwise class'll not be available for outside of package
package demo;
public class Myclass
{
        public void show()
        {
              System.out.println("Package function");
        }

when you will compile this file then it will create a class file named Myclass  you  must save this file in demo  named folder.Ones everything gos ok then you are ready to use this file.. consider following code where i am using this...
import demo.Myclass ;
//import demo.*;   for import all class in demo package
class MainFile
{
      public static void main(String args[])
      {
             Myclass ob=new Myclass();
             ob.show();
       }
}

A package can be nested like java.awt.event as i discussed above that every package should be save in same name folder so you will have to a folder in your current folder named as you want for package

package demo.demo2;
public class Myclass
{
       public void show()
       {
             System.out.println("Function from demo 2 package");
        }
}

You must make a folder named demo2 in demo folder.You can make more nested package as you want you just have make a folder.When user will use such package they'll have to provide all heir achy of package in this case it will be
import demo.demo2.*;
class packdemo
{
    public void show()
    {
         System.out.println("Nested package function");
     }
}
  • When you save this package in Bin folder then you can use (javac) for compile
  • If your package folder is outside of bin folder then you can use ( javac -classpath <java sourcefile>)
  • -classspath will search your package class file

Thursday 23 August 2012

Make a numeric Text Box In VB.net and C#

hi...........
Most of the time we want to a text box which can only take numeric value such as textbox design for taking input of age and we know age must be a number.Textbox is a control which takes string values by default for change its functionality follow instruction....
Key events occur in the following order:
  1. KeyDown
  2. KeyPress
  3. KeyUp
To handle keyboard events only at the form level and not enable other controls to receive keyboard events, set the KeyPressEventArgs..::.Handled property in your form's KeyPress event-handling method to true. Certain keys, such as the TAB, RETURN, ESCAPE, and arrow keys are handled by controls automatically. To have these keys raise the KeyDown event, you must override the IsInputKey method in each control on your form. The code for the override of the IsInputKey would need to determine if one of the special keys is pressed and return a value of true.

VB.Net


Wednesday 1 August 2012

How to Show Power Point Slide Show in Visual Basic

There are many way to show a power point slide show in vb form one can use OLE or a frame window
I'm showing it in a separate window. to show presentation do following steps

Make some declaration in general section 

  • Public oPPTApp As Object          
  • Public oPPTPres As Object
  • Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
          (ByVal lpClassName As String, _
           ByVal lpWindowName As Long) As Long
  • Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long

Function for show presentation

Private Sub slideShow() 
    Dim screenClasshWnd As Long
    Set oPPTApp = CreateObject("PowerPoint.Application")
    If Not oPPTApp Is Nothing Then
            Set oPPTPres = oPPTApp.Presentations.Open("Paste Your Presentation file path", , , False)
         If Not oPPTPres Is Nothing Then
             With oPPTPres                  
                          With .SlideShowSettings
                                 .ShowType = 1000
                                 .Run
                        End With
                Call SetWindowText(FindWindow("screenClass", 0&), APP_NAME)
        
        End With
       Else
        MsgBox "Error : Could not open the presentation.", vbCritical, APP_NAME
    End If
Else
    MsgBox "Could not instantiate PowerPoint.", vbCritical, APP_NAME
End If
End Sub

 

     

Monday 30 July 2012

How to get input in character type array in java

Hi ............
There are many way to get input in java. Java works on two type of stream 1. Character Stream 2. Byte Stream
Java treats Char data type different form c and c++. In C/C++ char data type hold 7 bit ASCII Character which is 0 to 127 characters but java char data type works on Unicode.
  • System.in.read() takes one character from user and return correspondence int value
  • for hold it we have to type cast in char
  • System.in.read() stop when user press enter its take it '\n'
class CharInput
{
           public static void main(String args[]) throws Exception
           {
                  char ar[]=new char[5];
                  int i;
                  for(i=0;i<ar.length;i++)
                  {
                          ar[i]=getChar();
                   }
            }
            static char getChar() throws Exception
            {
                   char ch=(char) System.in.read();
                   pressEnter();
                   return ch;
             }
             static void pressEnter() throws Exception
             {
                    while((char) System.in.read()!='\n');
              }
}  
  • As we know System.in.read() stop input when it encounter newline
  • i have make getChar function which is taking input from user and sure newline using pressEnter function
  • pressEnter is use to ensure newline character using while loop
  • loop stop when user press enter otherwise it looking in stream for new line