0


C++ is an object oriented programming (OOP) language. It was developed at AT&T Bell Laboratories in the early 1979s. Its initial name was C with classes, but later on in 1983 it was renamed as C++.
C++ language is an extension to C language and supports classes, inheritance, function overloading and operator overloading which were not supported by C language.

The object oriented feature in C++ is helpful in developing the large programs with clarity, extensibility and easy to maintain the software after sale to customers. It is helpful to map the real-world problem properly.

Objects Oriented Programming (OOP)In Object Oriented Programming, Objects which have data related to a person or item are used. The program can be written using many functional blocks. The functional block contains instructions similar to procedural programming.
                        Object Oriented Programming method is commonly used to develop software packages. C++ is one of the commonly used object oriented programming languages.

Characters used in C++ –
·         Alphabets
Upper case letters A to Z
Lower case letter a to z

·         Numbers
0 to 9

Special Characters
+
Plus
Double Quote
-
Minus
&
Ampersand
*
Asterisk
#
Hash
/
Slash
$
Dollar
\
Back slash
^
Caret
%
Percent
< 
Lesser than
|
Vertical bar
> 
Greater than
~
Tilde
=
Equal to
?
Question mark
(
Open Parenthesis
!
Exclamation Mark
)
Close Parenthesis
,
Comma
[
Open bracket
.
Full stop
]
Close Bracket
;
Semicolon
{
Open Set Bracket
:
Colon
}
Close Set bracket
Apostrophe
_
Underscore

White Spaces Characters: - A character that is used to produce blank space when printed in C++ is called white space character. These are spaces, tabs, new-lines, and comments.

Identifier – An identifier is a name having a few letters, numbers and special character _ (Underscore). It is used to identify a variable, function, symbolic constant and so on. It is a good practice to have identifiers with few letters; less than 8 letters is commonly followed with the first letter being an alphabet.
Ex:-
            c3
            sum
            PI
            sigma
            matadd

Rules for Forming Identifiers -
Identifiers are defined according to the following rules:
1.      It consists of letters and digits.
2.      First character must be an alphabet or underscore.
3.      Both upper and lower cases are allowed. Same text of different case is not equivalent, for example: TEXT is not same as text.
4.      Except the special character underscore ( _ ), no other special symbols can be used. 

Keywords or Reserved words – C++ language uses the following keywords which are not available to users to use them as variables/function names. Generally all keywords are in lower case although uppercase of same names can be used as identifiers.


asm
double
new
switch
auto
else
operator
template
break
enum
private
this
case
extern
protected
try
catch
float
public
typedef
char
for
register
union
class
friend
return
unsigned
const
goto
short
virtual
continue
if
signed
void
default
inline
sizeof
volatile
delete
int
static
while
do
long
struct

Added by ANSI C++ (New)
bool
export
reinterpret_cast
typename
const_cast
false
static_cast
using
dynamic_cast
mutable
true
wchar_t
explicit
namespace
typeid


Variables: - A variable is an identifier or a name which is used to refer a value and this value varies or changes during the program execution. A variable is written with a combination of letters, numbers and special character _ (underscore) with the first letter being an alphabet.
Ex: - c, fact, h34, total_amount etc
All variables have three essential attributes:
         the name
         the value
         the memory, where the value is stored.

Note the following points while writing a variable in C++ language:-
         Upper and Lower case alphabets are taken differently, so the variable SUM and sum are referring to different value.

         No special characters other than underscore ( _ ) are permitted.

         All variables used in a C++ program are declared with appropriate data types before the variable is assigned any value.

         Reserved words cannot be used as variables.

Variable Declaration - Before any data can be stored in the memory, we must assign a name to these locations of memory. For this we make declarations. Declaration associates a group of identifiers with a specific data type. All of them need to be declared before they appear in program statements, else accessing the variables results in junk values or a diagnostic error. The syntax for declaring variables is as follows:
data- type variable-name(s);

For example,
int a;
short int a, b;
int c, d;
long c, f;
float r1, r2;

Initializing variables - When variables are declared initial, values can be assigned to them in two ways:

1.      Within a Type declaration
The value is assigned at the declaration time.
For example,
int a = 10;
float b = 0.4 e –5;
char c = ‘a’;

2.      Using Assignment statement
The values are assigned just after the declarations are made.
For example,
a = 10;
b = 0.4 e –5;
c = ‘a’;

Literals or constants - A number which does not change its value during execution of a program is known as a constant or literals. Once an identifier is declared as constant at the time of declaration, its value can’t be changed during the execution of the program. Any attempt to change the value of a constant will result in an error message. A keyword const is added to the declaration of an identifier to make that identifier constant. A constant in C++ can be of any of the data types.
Ex:- const float Pi = 3.1215;

C++ Data Types : -

int – It refers integer. It can hold a signed or unsigned whole number within the specified range.

char – It refers to character. It can hold one letter/symbol. Char in C++ language is associated with integers to refer a letter/symbol as per ASCII which has assigned integer value for all letters/symbols used in programming.

float – It refers floating point or real number. It can hold a real number like 3.245453 or 5.87e3 with six decimal digits in decimal or exponential form. A float number using 6 decimal digits is called a single precision number.

Void data type - It is used for following purposes:
 It specifies the return type of a function when the function is not returning any value.
 It indicates an empty parameter list on a function when no arguments are passed.
 A void pointer can be assigned a pointer value of any basic data type.

Name
Description
Size*
Range
char
Character or small integer.
1byte
signed: -128 to 127 unsigned: 0 to 255

short int (short)

Short Integer.

2bytes
signed: -32768 to 32767 unsigned: 0 to 65535

int

Integer.

4bytes
signed: -2147483648 to 2147483647 unsigned: 0 to 4294967295

long int (long)

Long integer.

4bytes
signed: -2147483648 to 2147483647 unsigned: 0 to 4294967295

bool
Boolean value. It can take one of two values: true or false.

1byte

true or false
float
Floating point number.
4bytes
+/- 3.4e +/- 38 (~7 digits)
double
Double precision floating point number.
8bytes
+/- 1.7e +/- 308 (~15 digits)
long double
Long double precision floating point number.
8bytes
+/- 1.7e +/- 308 (~15 digits)
wchar_t
Wide character.
2 or 4 bytes
1 wide character


Precedence of operators in descending order
Level of Precedence
Operator
Description
Grouping
1
::
scope
Left-to-right
2
() [] . -> ++ -- dynamic_cast static_cast reinterpret_cast const_cast typeid


postfix


Left-to-right
3
++ -- ~ ! sizeof new delete
unary (prefix)
Right-to-left
* &
indirection and reference (pointers)
+ -
unary sign operator
4
(type)
type casting
Right-to-left
5
.* ->*
pointer-to-member
Left-to-right
6
* / %
multiplicative
Left-to-right
7
+ -
additive
Left-to-right
8
<< >>
shift
Left-to-right
9
< > <= >=
relational
Left-to-right
10
== !=
equality
Left-to-right
11
&
bitwise AND
Left-to-right
12
^
bitwise XOR
Left-to-right
13
|
bitwise OR
Left-to-right
14
&&
logical AND
Left-to-right
15
||
logical OR
Left-to-right
16
?:
conditional
Right-to-left
17
= *= /= %= += -= >>= <<= &= ^= |=
assignment
Right-to-left
18
,
comma
Left-to-right

Post a Comment

Comment Rules :
1. Do not post Adult/illegal Links.
2. Try to comment in only English Language.
3. Do not post other website's links which are useless.
4. Your Comment should be based on the Topic for other queries Kindly Visit our Contact Us Page.
5. Do not use Abusive Language.
6. Respect each other.
Thank You for following the rules. Please Comment....

 
Top