- C++ Introduction
- C++ Installation / Compiler
- C++ Keywords / Operators
- C++ Program Structure
- C++ Data Handling / Expressions

- C++ Flow Control / Statements
- C++ if-else Statement
- C++ Nested if Statement
- C++ switch Statement
- C++ Jump Statements / goto

You can apply the modifiers **signed**, **unsigned**, **short** and **long** to character and integer base types. However you may also apply **long** to double.

Type | Approximate Size |
---|---|

short unsigned signed short |
2byte 2bytes 2bytes |

int unsigned int signed int |
2byte 2bytes 2bytes |

long unsigned long signed long |
4byte 4bytes 4bytes |

Type | Approximate Size |
---|---|

char unsigned char signed char |
1byte 1bytes 1bytes |

Type | Approximate Size |
---|---|

float double long double |
4byte 8bytes 10bytes |

C language Operators and Expressions - C ++ Operators - C++ is very rich in built-in operators. In fact, C++ places more significance on operators than most other computer languages do.

It provides operators for five basic **arithmetic calculation** : addition, subtraction, multiplication, division and remainder which are +, -, *, / and % respectively.

Operator | Name | Example | Result |
---|---|---|---|

+ | addition | 6 + 5 | 11 |

- | subtraction | 6 - 5 | 1 |

* | multiplication | 6 * 5 | 30 |

/ | division | 60 / 5 | 12 |

% | addition | 60 % 5 | 0 |

C++ includes two useful operators these are the increment and decrement operators, **++** and **--**. The C++ name itself is influenced by the increment operator ++. The operator **++** add **1** to its operand, and **--** subtract **1**.

a = 15;

a++ **or** ++a will produce the result a = 16.

a = 15;

a-- **or** --a will produce the result a = 14.

**Note** : That a++ and a-- are referring the **post-fix** increment and decrement operation, and ++a and --a are referring the **prefix** increment and decrement operation.

Relation refers to the relationships that values (or operands) can have with one another.

Operator | Name | Example | Result |
---|---|---|---|

== | comparison (equality) | 6 == 5 | false |

< | less than | 6 < 5 | false |

<= | less than or equal to | 6 <= 5 | false |

> | greater than | 6 > 5 | true |

>= | greater than or equal to | 6 >= 5 | true |

!= | not equal to | 6 != 5 | true |

The previous section discussed about relational operators that establish relationships among the values. This selection talks about logical operators that refer to the ways these relationships (among values) can be connected.

Operator | Name | Example | Result |
---|---|---|---|

&& | and | (6 <= 6) && (5 < 3) | false |

|| | Or | (6 <= 6) || (5 < 3) | true |

! | Or | !(6 <= 6) | false |

C++ offers a conditional operator (**?:**) that stores a value depending upon a condition, this operator also called **Ternary operator**. The general condition follows :

`expression1? expression2 : expression3`

result=marks>=50?'P':'F';

The identifier **result** will have value **'P'** if the test expression **marks >= 50** evaluates to true(1) otherwise **result** will have **'F'**.

There are a lot many other operators in C++, other than the ones discussed here. But in this section, we are discussing two of them that are of relevant use to you right now. two operators are : **sizof** and **comma** operator.

**The sizeof Operator :**

`float fl;`

cout<<"The sizeof float variable fl is"<<sizeof fl;

cout<<"The sizeof integers is"<<sizeof (int);

**Note :** Assuming that integer-size is 2 bytes and float-size is 8 bytes.

**The Comma Operator :**

`b = ( a = 3, a + 1 );`

First assigns **a** value 3 and then assigns **b** the value **a + 1**.

**Note :** The parentheses are necessary because the comma operator has a lower precedence than the assignment operator.