Educational Notes-Computer Programing C++ - Educational Notes

Click & Cash

Breaking

Home Top Ad

Post Top Ad

Thursday, December 10, 2015

Educational Notes-Computer Programing C++

Introduction to C++:

C++ is a powerful computer programming language. It is procedural and sequential language. Usually it is used in making software. It is simplest programming language and considers basic programming language for newbie.

Short history of C++:

Master Martin Richard developed first programming language known as BCPL in 1967. It was used to write operating systems and compilers then B programming language discovered by ken in 1969. Both BCPL and B were “type-less” languages.
In 1972Dennis Richard developed c language. C was an advanced form of B. It had many concepts of BCPL and B.
 The C++ programming languages is an extension of C that was developed by Bjarne Stroustrup in the early 1980s at Bell Laboratories.

How C++ works:

The source code of c++ is stored on a disk with file name .cpp at end. The program can be written using compiler (Borland C++ or Turbo C++). When program compiled, source code is converted into machine language and save with file name .obj at end (i.e. extension .obj) on disk and executable code is stored in file with name .exe at end (i.e. extension .exe).

For example:

Suppose we write a program and save it by giving it name Big.cpp. After compilation the object code is saved in file Big.obj (converted in machine language) and executable code store in file Big.exe.

How to write C++ program (Structure):

A C++ program consists of three main parts:
  • Preprocessor directives
  • The main function
  • C++ Statement
First we will see a program and then discuss them separately by their functions.

#include<iostream.h>
void main()
{
cout<<"This is my first progrgame";
}

In this program:

Coding
Function of coding
#include<iostream.h>                               
Preprocessor directive.
void main()                                                 
Main function
{cout<<"This is my first progrgame";}     
C++ statement

Preprocessor directives:

Preprocessor directives are instructions given to compiler before the beginning of program. The preprocessor directives consist of instructions for the compiler. Preprocessor directives start from (#) sign and the keyword “include”. These are basically used to add header files in the program.

Header File:

Header file is a source file of C++ that contains definition of library function. A header file is added if the function defined in it is to be used in program. As mentioned before the preprocessor directive #include in used to add header file into program. The header file which added will closed in <> brackets. As example is given before #include<iostream.h>. Here iostream.h is header file.
The syntax to include a header file is 
 “#include<name of header file>”

For example:

If we write a program which has some math functions for example if we are calculating square root of numbers then header file used for this purpose will be math.h because it has all functions about math. In this way we can save time by using built-in functions.

The Main ( ) Function:

The Main function indicates the beginning of C++ program. It must be written before every program written in C++. When program executed the control goes directly to the main () Function. After writing main Function we write curly braces and program must be written in between these curly braces.

The syntax of main () function is:
Void main ()
{
Program statements……

C++ Statement:              

It is considered as main body of the program. The statements considered as main body of the program. Each statement will end with semicolon (;). ; means statement is terminated.
C++ language is case sensitive language so all words written in c++ will be small alphabet or lower case letters. Case sensitive means in c++ meaning of (a) and (A) is not same for example in one place you write a and other place you are calling it with name A then this will give error. In this way it is a Case sensitive language.

No comments:

Post a Comment

Post Bottom Ad

Pages