Introduction to C++
C++ CHARACTER SET
It is the set of all valid characters that a language can recognize . It represents any letter, digit, or any other sign .C++ character set:
LETTERS A to Z and a to z
DIGITS 0 -9
SPECIAL SYMBOLS + -* ^ \ [] {} = != < > . ‘ ‘ ; : & #
WHITE SPACE Blank space , horizontal tab, carriage return , Newline, Form feed.
OTHER CHARACTERS 256 ASCII characters as data or as literals.
TOKENS:
The smallest lexical unit in a program, it can be any keyword, identifier, literal, puncutator or operator.
KEYWORDS :
The reserved words used by the compiler examples are:
auto continue float new signed volatile
short long class struct else inline
delete friend private typedef void template
catch friend sizeof union register goto
IDENTIFIERS:
An arbitrary name consisting of letters and digits and or underscore to identify a particular word. For example
Pen time580 s2e2r3 _dos _HJI3_JK
LITERALS:
The data items which never changes its value throughout the program. Different types of literals are:
- Character constant
- Floating constant
- String constant.
Integer constant :
Whole numbers without any fractional part. An integer constant must have at least one digit no decimal point. It may contain either + or _.
e.g 15, 1300, -58795.
Character Constant:
A character constant is single character which is enclosed within single quotation marks e.g. ‘ A’
Floating constant:
These numbers have the fractional part, may be positive or negative e.g 2.0, 17.5, -0.00256
String Literals:
It is a sequence of letters surrounded by double quotes. E.g “abc”.
PUNCTUATORS:
The characters that are used as punctuators in C++ are: [ ] { } ( ) , ; : * ……….. = #
OPERATORS:
Meant for computation when applied to variables and other objects and form mathematical expression. Following are some operators used in C++
Unary operators: Need only one operand e.g. & , + , ++ , -- ! .
Binary operators: Require two operands to operate upon. Following are some of the Binary operators.
Arithmatic operators :
+ Addition
_ substraction
A* Multiplication
/ Division
% Remainder.
Logical Operators :
&& - logical AND || - Logical OR
Relational Operator:
< Less than
> Greater than
<= Less than equal to.
>= Greater than equal to.
== Equal to.
!= Not equal to.
Conditional operator: ? (question ) : ( colon )
Assignment Operator:
= assignment operator
*= Assign Product.
/= Assign quotient
%= assign Remainder
&= Assign bitwise AND
^= Assign bitwise XOR.
|=Assign bitwise OR