C++ Programming Language

Only available on StudyMode
  • Topic: Source code, Floating point, Data types
  • Pages : 18 (4580 words )
  • Download(s) : 126
  • Published : December 10, 2012
Open Document
Text Preview
Institute of Engineering, Information and Technology

Structure of Programming Language
“C++ Programming Language”

INSTRUCTOR:
SCLP

SUBMITTED BY:
UC

HISTORY OF C++

In the early 1970s, Dennis Ritchie of Bell Laboratories was engaged in a project to develop a new operating system. Ritchie discovered that in order to accomplish his task he needed the use of a programming language that was concise and that produced compact and speedy programs. This need led Ritchie to develop the programming language called C..   In the early 1980's, also at Bell Laboratories, another programming language was created which was based upon the C language. This new language was developed by Bjarne Stroustrup and was called C++. Stroustrup states that the purpose of C++ is to make writing good programs easier and more pleasant for the individual programmer. When he designed C++, he added OOP (Object Oriented Programming) features to C without significantly changing the C component. Thus C++ is a "relative" (called a superset) of C.

Introduction

When one begins to write a program, the first action should be to define the variables that the program needs; variables are places in memory in which to store data items. Next, one writes the instructions to input values from the user (say, via the keyboard) and store those values in the variables. Now that the variables have values, one can write the needed calculation instructions and finally the instructions to display the results. This chapter concentrates on numeric type of variables and constants along with their basic input and output instructions.

Use of C++:

C++ is used by hundreds of thousands of programmers in essentially every application domain.
C++ is being highly used to write device drivers and other software that rely on direct manipulation of hardware under real time constraints.
C++ is widely used for teaching and research because it is clean enough for successful teaching of basic concepts.

The Compiler

A C program is made by running a compiler which takes the typed source program and converts it into an object file that the computer can execute. Firstly, the program is written in the form of a number of text files using a screen editor. This form of the program is called the source program. It is not possible to execute this file directly. Secondly, the completed source file is passed to a compiler--a program which generates a new file containing a machine code Translation of the source text. This file is called an object file or executable file. The executable file is said to have been compiled from the source text.

Basic elements which make up a C++ program.

1. comments
2. preprocessor commands
3. functions
4. declarations
5. variables

1. Comments

Comments are a way of inserting remarks and reminders into a program without affecting its content. Comments do not have a fixed place in a program: the compiler treats them as though they were white space or blank characters and they are consequently ignored, it helps the user to identify what is really the program. Ex.

/* ...... comment ......*/

2. PREPROCESSOR COMMAND

Pre-processor commands are distinguished by the hash (number) symbol #. is a command which tells the preprocessor to treat the file iostream as if it were the actually part of the program text, in other words to include it as part of the program to be compiled.

Ex.
#include <iostream>

3. Functions

A function is a module or block of program code which deals with a particular task. Making functions is a way of isolating one block of code from other independent blocks of code. Functions serve two purposes. They allow a programmer to say: `this piece of code does a specific job which stands by itself and should not be mixed up with anything else', and they make a block of code reusable since a function can be reused in many...
tracking img