Thursday, March 19, 2009

Tutorial: Learn All The Basics Of C++ Language:page 3

CONSTANT


These are the items which cannot be changed during the program execution. Every constant used in a program as a type that is determined by its form and a value .

They are mainly of 3 types:-
• Numeric Constant
• String Constant /Literals
• Character Constant
• Floating Constant

INTEGER CONSTANT


One whole number without any factorial part. The integer constant may be Decimal (base 10), Octal (base 8), and Hexadecimal (base 16).

CHRACTER CONSTANT


A character constant in C++ can be any of the valid in ASCII character and is enclosed in single quotes (‘‘)
For e.g.:- char grade=’A’

General Character can be represented by above method but for special character like tab, backspace etc. C++ provides escape sequence as already told by me. It is represented by backslash (\) followed by one or more character.
Escape sequence non graphic characters:-

\a = Audible Bell
\b = Backspace
\f = Formfeeds
\n = New line (\n is same as endl \n is used inside quotes but endl doesn’t)
\r = Carriage Return
\t = Horizontal Tab
\v = Vertical Tab
\\ = Backslash
\’ = Single Quote
\”= Double Quote
\? = Question Mark
\On = Octal number
\xHN = Hexadecimal Number

NOTE: -- These Escape sequence should always be written inside ““double quotes.
As “\n”.

FLOATING CONSTANT


These are also called real constants, they contain factorial part too. A real constant in exponent form has two parts: a mantissa and an exponent.

SEPARATORS

( ) = Parentheses
These are used for function call and function parameter.
{ } = Braces
These are used for blocking codes having simple or compound statement.
[ ] = Brackets
These are used for enclosing subscripts in case of a single and multi dimensional arrays.
, = Comma
These are used for separating arguments list in a function.
; = Semicolon
These are used as a statement terminator.
: = Colon

These are used in case of a labeled statement.

AIRTHMATICAL OPERATORS

Some of the arithmetical operator are +,-, *, /, %.
+ = Add
Gives the addition of two or more numbers. (A+B)
- = Subtraction
Gives the subtract of two or more number (A-B)
* = Multiplication
Gives the multiple of two or more numbers (A*B)
/ = Divide
Gives the divide of two or more numbers (A/B)
% = Remainder=Modulus
Gives the remainder of two or more number (A%B)
Note: Where A & B are integers.


KEY WORDS


Keywords are reserved words in C++. They convey special message to language compiler. It has some of the following Keyword but we will learn some of them here.
asm, continue, float, new, signed, try, auto, default, for, operator, sizeof, typed, break,
delete, friend, private, static, union, do, goto, protected, struct, unsigned, while, do while,

DATA TYPES

They are used to indicate char, int, float, double, long double etc .The chart showing the allocation is as follows:-



The following are the meaning of the words written in table:-
# Char(For Character)
# Int (For Integer)
# Double (For Integer)
# Long (For Integer)
# Long Double (For Integer)
# Float (Decimals)
# Void (For non returning function)

RELATIONAL OPERATOR


<= Less than >= Greater than
= - Equal to (Assignment Operator)
== - Double Equal to (Conditional Operator)

LOGICAL OPERATORS

&& - To give and logic
! - Not equals to
|| - To give or logic

CIN COUT


The Identifier cout>> is a predefine object that corresponds to the standard output stream.
The Identifier cin>> is a predefine object that corresponds to the standard input stream.
“<<” – Output of data. The output of data is known as insertion output to operator. “>>” – Input of data.

Input of data is known as extraction or to get data from the operator.
Cout<<>> for getting the info. from user.

No comments:

Post a Comment