Thursday, 31 May 2012

The Compilation process


•The objective of the compiler is to transform a program written a high-level programming language from source code into object . Programmers write in a high-level programming languages from source code into object code. Programmers write program in a form called source code. Source code must go through several steps before it becomes an executable program.
The first step is to pass the source code through a compiler, which translates the high-level languages instruction into object code. At last it producing an executable code. After produced object code , it is pass to the linker. The linker combines modules and gives real values to all symbolic addresses.

•Every high-level programming language comes with a compiler. The compiler the language, because it defines which instructions are acceptable.
•Compilers translates source code into object code, which is unique for each type of computer, many compilers are available for the same language.
General models of compilers(Phases of C)
1.Lexical analysis : recognition of basic elements and creation of uniform symbols.
2.Syntax analysis : recognition of basic syntactic constructs through reductions.
3.Interpretation (Symantec analysis) : definition of exact meaning, creation of matrix and tables by action routines.
4.Machine independent : creation of more optimal matrix.
5.Storage assignment : modification of identifier and literal tables. It makes entries in the matrix that allow code generation to create code that allocates dynamic storage, and that also allow the assembly phase to reserve the proper amounts of static.
6.Code generation : use of macro processor to produce more optimal assembly code.
7.Assembly and output : resolving symbolic addresses and generating language.
•Compiler also manage the database, in the database it manages
A.Source code
B.Uniform symbol
C.Terminal table
D.Identifier table
E.Literal table
F.Reductions
G.Matrix
H.Code productions
I.Assembly code
J.Relocatable object code
1.Source code : program
2.Uniform symbol table : Consist of a full or partial list of the token as they appear in the program. Created by lexical analysis and used for syntax analysis and Symantec analysis.
3.Terminal table :  a permanent table which lists all key words and special symbols of the language in symbolic form.
4.Identifier table : it contains all variables in the program and temporary storage and any information needed to reference or allocate storage for them.
5.Literal table : it contains all constants in the program creation and use similar to the identifier table.
6.Reductions : permanent table of decision rules in the form of patterns for matching with the uniform symbol table.
7.Matrix : intermediate table of decision rules in the form of pattern for matching with the uniform symbol table.
8.Code productions : permanent table of definitions. There is one entry defining code for each possible matrix operator.
9.Assembly code : assembly language version of the program which is created by the code generation phase.
10.Reloadable object code : final output of the assembly phase, ready to be used as input to loader.




Compilers and interpreters


•When we work with high level language then to work on computer it must be translated into machine language. There are 2 kinds of translator- compilers & interpreters.
•High level languages are called either compiled language or interpreted languages.
•In computers there are so many languages which use compilers and interpreters.
•Ex. C, C++ etc are the compiled language.
Basic,Visual basic is an interpreted language


Definition

•Compilers : In a compiled language, a translation program is run to convert the programmers entire high-level program, which is called the source code, into a machine language code. This translation is called compilation. The machine language code is called the object code and can be saved and code can be run immediately or later.
Interpreter : In an interpreter language, a translation program converts each program statement into machine statement one by one and execute it. Translation and execution occurs immediately, but at a time it executes only statement. Unlike compiler it does not create an object code & store it. These means in a program where one statement is executed several that statement is converted to machine language each time it is executed


Monday, 28 May 2012

Skills For Good Programming

Wanna be a good Programmer?????
Don't worry you don't have to do something new to tough, just keep the following points in your mind and programming will be as simple as surfing on internet......
The very first thing is that you should set your mind that you have to solve a problem without thinking that you have to do programming. If your mood is all set for programming then just pick up the problem and try to find all the alternative logic to solve that particular problem.
After finding all the alternative solution, analyse all the alternatives and compare them to choose the best alternative.
Now you have the logic to solve the problem, so half of your problem is solved. Rest of the problem would be solved through programming. Now you should think of programming, don't worry it's not mandatory that you must know each and every concept of that programming language which you are going to use. Just start programming without thinking that how will you do it, instead just do it.
If you encounter any problem about the concept just go through the book or the best way is to see the example of it on internet. Just keep on going and finaly you will have the complete solution of the problem.

International Institute of Professional Studies


INTERNATIONAL INSTITUTE OF PROFESSIONAL STUDIES
International Institute of Professional Studies is one of the well known institute of India. It was established in 1992 specially as a postgraduate institute. It is a department of Devi Ahilya Vishwavidyalaya Indore. It is recognized by AICTE. This institutes provides the development of professional quality of an individual. The procedure for the admission in the institute is through well known CET exam cunducted every year. Many courses are offered by the institute such as MCA, M.TECH, MBA etc. In addition to these courses institute offers  specialized courses in tourism and management.

Program in Java to check a given number is prime number


class Prime_number {
  public static void main(String[] args) {
  int num = 11;
  int i;
  for (i=2; i < num ;i++ ){
  int n = num%i;
  if (n==0){
  System.out.println("not Prime!");
  break;
  }
  }
  if(i == num){
  System.out.println("Prime number!");
  }
  }
}

Selection sort program in Java


class SelectionSorting{
public static void main(String arg[]){
int a[]={3,30,4,12,1,2,34,22,4,3,5,8};
System.out.println("\n\nInput values:");
for(int i=0;i<a.length;i++){
System.out.print(" "+a[i]);
}
for (int i = 0; i < a.length; i++){
   int min = i;
int j;
/*
        *  Find the smallest element in the unsorted list
        */
     for (j = i + 1; j < a.length; j++) {
     if (a[j] < a[min]){
min = j;
}
}
/*
*  Swap the smallest unsorted element
into the end of the sorted list.
*/
int T = a[min];
a[min] = a[i];
a[i] = T;  
        }
System.out.println("\n\n\nSorted values:");
for(int i=0;i<a.length;i++)
{
System.out.print(" "+a[i]);
   }
}
}

Program in java to sort array of strings


import java.util.Arrays;
class SortString

{
public static void main(String args[])
{
String[] names = {"Zoe", "Alison", "David"};
Arrays.sort(names);
       System.out.println(Arrays.toString(names));


}
}