Website is updated! 06:37 PM 09/01/2015

Pgesturia

Pgesturia

Friday, 21 November 2014

learning C language chapter 2

Learning C language using OOP

Chapter#2

Introduction to C++

Contents


  1. History of C++
  2. Preprocessor directive
  3. Header files
  4. Main() function
  5. C++ statements
  6. Token
  7. White spaces
  8. Linker


1. History of C++

                 Many new programming languages appeared during the 1960's.
The computers at that time were still in early stage of development.The language
ALGOL 60 was developed as an alternativ to FORTRAN.The language CPL was
developed in 1963.It was more specific for concrete programming tasks of that time
then ALGOL or FORTRAN.

KEN THOMPSON created the B language in 1970.C language was derived from
B language.

C++ was refined during 1980's and it became a unique language.It was very much
compatible with the code of C and provided the most important characteristics of C.

2. Preprocessor directive

                 It is an instruction given to compiler before execution of program.
It is also known as compiler directive.The preprocessor directives are processed
 by a program called Preprocessor. It is a part of C++ compiler.The semicolon
is not used at the end of preprocessor directive.

Types of preprocessor directives.

  • Include 
  • Define

Include

It enables the program to access a library.Each library contains different header files.
It is used to include HEADER files in the program.

Syntax

#include<standard header file>

Define

The define directive is used to define a constant.Its starts with the symbol #.It is not
terminated with semicolon.It can be used anywhere in program.

Syntax

#define identifier value

3. Header Files

Header files are the collection of standard library functions . There are many header 
files for different purposes.Many header files are included in one program.the extension
of header files is .h. It is used to include header files in programs.

syntax

#include<conio.h>
#include<iostream.h>

Learn C language Basic structure

4. Main() Function

Main function is the starting point of a C++ program.When the program is run,the control
enters main() function and starts executing its statements.Each program must contain
main() function.If the program does not contain main function,it may be executed but 
not run at all.

Syntax

main( )

{
   
   body or C statement

}

5. C++ statements

A statement in C++ language is an instruction for the computer to perform a task.
Computer performs these instructions one by one in same sequence in which these
instructions are written.

6. Tokens

A token is a language element that is used to form a statement.C++ statement may
consist of different tokens.Different types of tokens are :
  • Keyword
  • Identifier
  • Constant 
  • String literals
  • Operators
  • Punctuators

7.White Spaces

White spaces are used in programs to increase readability.Different types of white
spaces include space,tab and carriage return etc.A single line can be written in 2 or more
lines in order to enhance its readability.

8. Linker

The process of linking library files with object program is called linking.A library file
must be linked with the object file before the execution of program.A program that combines
 the object program with additional libraries is known as linker.

0 comments: