This blog consists of C and C++ programs. C and C++ programming is the basics to learn any programming language. Most of the programs are provided with their respective outputs. This blog also contains Data Structures programs using Object-Oriented Programming (C++). Some of the best books for learning C and C++ programming are also mentioned.

Friday 20 September 2013

Introduction to C++ Programming



Introduction
C++ was developed at AT & T Bell laboratories in the early 1980s by Bjarne Stroustrup. The name C++ (pronounced as C plus plus) was coined by Rick Mascitti where “++” is the C increment operator.

C++ character set
Like the C language, C++ also comprises a character set from which the tokens (basic types of elements essential for programming coding ) are constructed. The character set comprises of “A” .. “Z” , “a” .. “z”, 0 .. 9, +, -, /, *,\, (, ), [, ], {, }, =, !=, <, >, . , ’ “ ; : %, ! , &, ?, _, #, <=, >=, @, white space, horizontal tab, carriage return and other characters.

A quick recap of the basic types : The basic types are collectively called as TOKENS. A token is the smallest individual unit in a program. Tokens are classified as shown in Figure.

Data Types
Data Types are the kind of data that variables hold in a programming language. The ability to divide data into different types in C++ enables one to work with complex objects. Data is grouped into different categories for the following two reasons :
  • The compiler may use the proper internal representation for each data type.
  • The programmer designing the programs may use appropriate operators for each data type. They can be broadly classified into the following three categories.
  • User defined type
  • Built-in type
  • Derived type

The broader classification is indicated in the Figure.

Variables
The name assigned to a data field that can assume any of a given set of values is defined as the variable. For example consider the following group of statements
int num;
num=5;
The statement int num; may be interpreted as “num is a variable of the type integer “. The assignment statement num = 5 may be interpreted as the value 5 is stored in the variable num.

Variables are user defined named entities of memory locations that can store data.

Variable names may contain letters, numbers and the underscore character(_). Names must begin with a letter or underscore. (However names beginning with an underscore are reserved for internal system variables). Names are case sensitive, which means that it differentiates between lower case and upper case letters.

No comments:

Post a Comment