C++ Character Set
C++ Character Set
Character Set is a set of valid Characters that a language can recognize.
- Letters A-Z, a-z
- Digits 0-9
- Special Characters Space + - * / ^ \ () [] {} = != <> ' " $ , ? _ # <= >= @
- Formatting Characters Backspace, Horizontal Tab, Vertical Tab, Form Feed, Carriage Return.
- A character that is used to produce blank space.
- These are spaces, tabs, new lines and comments.
C++ Uses the following types of tokens:-
*Keyword
*Identifiers
*Literals
*Punctuators
*Operators
Identifiers- The Identifier is a sequence of characters taken from C++ character set.The Rules for creation of an Identifier are:
- An Identifier can consist of alphabets, digits and underscores.
- It must not start with a digit.
- C++ is case sensitive.
- It should not be a reserved word(keyword).
Literals or Constants-A number which does not change its value during execution of a program is known as a constant or literals.
Operator- An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations.
*Arithmetical Operators
*Relational Operators
*Logical Operators
*Bitwise Operators
*Precedence of Operators
*Special Operators
*Escape Operators
Arithmetical Operators-An Operator that performs an arithmetic operation such as+,-,*,/ or % is called arithmetic operator.
Relational Operator
- The Relational Operators are used to test the relation between two values.
- All Relational Operators are binary operators and require two operands.
- Example : == != > < >= <=
Logical Operators-It takes true/false value as operands and compute new true/false value.
Example &&-Logical AND
||- Logical OR
!- Logical NOT
Bitwise Operators-Bitwise Operator works on bits and perform bit by bit operation.
Example &-bitwise AND
|-bitwise OR
^-bitwise exclusive or(XOR)
~-bitwise negation and compliment.
Special Characters(Increment & Decrement)
- The increment operator (++) adds 1 to its operand and the decrement operator (--) subtracts 1 from its operand.
- x=x+1;is same as x++;
- x=x-1;is the same as x--;
- Both the increment and decrement operator can either precede (prefix) or follow (postfix) the operand.
- x++,x-- Post Increment/Decrement
- ++x,--x Pre Increment/Decrement
Comments
Post a Comment