NCERT Computer: Chapter 7 – Introduction to C + + Part 5

Download PDF of This Page (Size: 279K)

4. Punctuators

The following characters are used as punctuators in C++.

Brackets [ ] opening and closing brackets indicate single and multidimensional array subscript.

Parentheses ( ) opening and closing brackets indicate functions calls, function parameters for grouping expressions etc.

Braces { } opening and closing braces indicate the start and end of a compound statement.

Comma , it is used as a separator in a function argument list.

Semicolon ; it is used as a statement terminator.

Colon : it indicates a labelled statement or conditional operator symbol.

Asterisk * it is used in pointer declaration or as multiplication operator.

Equal sign = it is used as an assignment operator.

Pound sign # it is used as pre-processor directive.

5. Operators

Operators are special symbols used for specific purposes.

C++ provides six types of operators.

Image of Operators

Image of Operators

Image of Operators

Arithmetical operators

An operator that performs an arithmetic (numeric) operation: +, -, *, / , or %.

The following table shows the arithmetic operators.

Image of Arithmetical Operators

Image of Arithmetical Operators

Image of Arithmetical Operators

Relational operators

The relational operators are used to test the relation between two values. All relational operators are binary operators and therefore require two operands.

A relational expression returns zero when the relation is false and a non-zero when it is true. The following table shows the relational operators.

Image of Relational Operators

Image of Relational Operators

Image of Relational Operators

Example 1

The following statements are true.