Tuesday, 23 April 2013

SIMPLE JAVA PROGRAM FO ADDITION OF TWO NUMBERS USING 3 VARIABLES

SIMPLE JAVA PROGRAM FO ADDITION OF TWO NUMBERS
 USING 3 VARIABLES

import java.lang.*;
class add
{
public static void main(String args[])
{
int a=10,b=20,temp;// HERE A,B,TEMP IS VARIABLES
temp=a+b;//TEMP VARIABLE STORES ADDITION OF A,B
System.out.println("temp="+temp);
}
}



OUT PUT:-
temp=30

Monday, 15 April 2013

Difference between compiler and interpreter


Compiler
A compiler is a piece of code that translates the high level language into machine language. When a user writes a code in a high level language such as Java and wants it to execute, a specific compiler which is designed for Java is used before it will be executed. The compiler scans the entire program first and then translates it into machine code which will be executed by the computer processor and the corresponding tasks will be performed.  

Shown in the figure is basic outline of the compilation process, here program written in higher level language is known as source program and the converted one is called object program. 

Interpreter
Interpreters are not much different than compilers. They also convert the high level language into machine readable binary equivalents. Each time when an interpreter gets a high level language code to be executed, it converts the code into an intermediate code before converting it into the machine code. Each part of the code is interpreted and then execute separately in a sequence and an error is found in a part of the code it will stop the interpretation of the code without translating the next set of the codes.  

The differences between compiler and interpreter are :-