Tuesday 14 June 2016

Elements of programming-1:



This series is going to contain fundamentals of programming. it applies to all the major programming languages.
Variables

Variables are name of memory location. If we want to store any kind of data in memory it has to be  named.  Before using a variable it has to declared that what kind of data we are going store in that variable(int, float or char). In c language any variable declarations must be the first statement in main function.  Advanced languages(c++, java,c#) allow variables to be declared at any line .

Compiler:

In a program what we write are called as high level languages. It  can not be understandable by a computer. It has to be translated in to machine language(0 or 1). That job is done by compiler. So compilers are the software which translate high level language into machine level language.

Interpreters

Interpreters do the same work as compiler. The primary difference between compiler and interpreter is interpreters compile the program line by line where as compiler compiles the whole program at once.

Comments:
Comments are used for documentation purposes. It will be ignored by the compiler.
Single line  comments starts with //.
Multi line comment start with /* and ends with */.
Examples:
//this is a single line comment.
/*this is a
Multiline comments*/

IDENTIFIER

An identifier is the name given to the programming elements such as variable,method,class and objects.
There are some naming rules:
It can contain alphabets, digits and underscore(_)
Special characters other than underscore are not allowed.
Spaces not allowed in a identifier.
It should not be a keyword.

Key words:

Every language contain keywords which has a special meaning to the compiler. We can not use it for another purposes.for example we can not use it for naming an identifier
Example for keywords:
Int, do, while,for,if
     To be                continued(MUTHUKARTHIKEYAN,MADURAI)