Data Handling

C++ is a strongly typed language.It provides a predefined set of data types 
for handling the data it uses.Data can be of many types like character
numbers, fractions, strings etc.
C++ supports three data types.
 	1.Built-in datatypes
 	2.User defined datatypes
 	3.Derived datatypes.

Built in Datatypes

Integer         : 2 bytes
Character       : 1 byte
Float           : 4 bytes
Double          : 8 bytes
Void            : 0 bytes

Datatype Modifiers

Short - A short integer is atleast 2 bytes. 
Short reduces the size of datatype by half.
Long - A long integer is atleast 4 bytes.
 Is used to store values beyond the storage capacity of the basic datatypes.
Signed - Holds both positive and negative.
Unsigned - Holds only positive values. 
Type Size(byte) Range
Short 2 -32768
To
32767
Int 2 -32768
To
32767
Long 4 -2,147,483,648
To
2127,483,647
Char 1 -128 to 127
Float 4 3.4*10^-38
To
3.4*10*38-1
Double 8 1.7*10^-308
To
1.7*10^308-1
Long Double 10 3.4*10^4932
To
1.1*10^4932-1

Character Set:

A set of valid characters that a language can recognise.
A character set should always be enclosed in single quotation.
C++ has the following character set.
Letters                 :      A-Z,a-z
Digits                  :      0-9
Special symbols         :      + - * / ^ \(){}[]= < > <= >=
Special symbols         :      ; : % ! & ? _ # @

Identifiers:

Identifiers are the names given to the different parts of the programs.
Ex: variables, functions, classes, arrays, objects etc. 
There are some rules associated with naming these.

Only alphabets, digits and underscores permitted.
keywords are not permitted. But keyword with changed case is valid.
Digits are not permitted in the beginning.

Ex: Name, name_1,_Sum,firstnumber,third_num, SWItch, FOR etc.

Escape Sequences :

Represents a single character hence consumes 1 byte.
Audible bell 		\a            Backspace                           \b
Horizontal tab 		\t            Vertical tab                        \v
New line 		\n            Null                                \0

punctuators:

[ ] 	:       indicates array subscript
( ) 	:       function call, function parameters
{ } 	:       indicates start and end of compound statement.
( ; )	:       statement terminator
( * ) 	:       pointer declaration
(#)		:       preprocessor directive

Operators:

Unary 		 :  &, *, +, -, ~, ++, - -, !
Arithmetic 	 :	+, -, *, /, % 
Relational	 :	>, <, > =, < =, = =, ! = 
Logical		 :  &&, ||, ! 
Increment 	 :	+ + 
Decrement	 :	- -
Assignment	 :	+=, -=, *=, /=, %= 
Conditional	 :	? : 
Bitwise		 :	&, |, ^

Declaration of variables

Int                 :               int a;
Float               :               float a;
Char                :               char a;
Double              :               double a;
Long Double         :               long double a;

Symbolic variables

Rvalue - Data value stored at some location in memory.
Lvalue - Memory address of data value.

Initialisation of variables

int a=10;
int a(10);
int a=int(10);

Dynamic initialisation

int a;
a=b+c;

Access Modifier Const

const int x=10;
x--;--->Gives error
The value of x is 10 throughout the program. It cannot be changed.

Iostream objects

 	cin>> console input
 	cout<< console output

User Defined Datatypes

Class - Represents a group of similar objects. 
The keyword ‘class’ is used to represent class.
Structure - A collection of different datatype variables under a single name. 
The keyword ‘struct’ is used to represent structure.
Union - A union is a special datatype that enables storage of different datatypes 
in single memory location. Is defined by the keyword ‘union’.
Enumerator - These are defined with a set of custom identifiers known as enumerators,
as possible values. ‘enum’ keyword is used to define an enumerator.

Derived Datatypes

Array - Represents a collection of elements of the same data type of a 
fixed size with a single name. A specific element of an array is accessed by its index.
Function - A function is a self-contained block of statements which are kept
together to perform a specific task. Every c++ requires at least one function called the ‘main()’.
Pointer  - All the data values used for processing are kept in memory of computer
and each memory has a memory address associated with it.
Pointers are used to access these memory addresses.
Reference - A reference variable is an alias name for an existing variable.

Leave a Reply

Your email address will not be published. Required fields are marked *