Basic Letters:: Constants
Basic Letters:: Constants
Language Basics:
Here, you can split your journey of learning C++ language in the following four
steps:
1. Basic Letters
2. Identifiers
3. Instructions
4. Program
1. Basic Letters :
Alphabets A to Za to z
Digits 0 to 9
Special Symbol example: ~ ‘ ! @ # % ^ & * ( ) _ – + = | \ { } [ ] : ; “ ‘ < > , . ?
2. Identifiers:
Combination of letters becomes an identifier. Identifier is the smallest unit in
the program which has some meaning. You are going to learn following
identifiers:
-Constant
-Variables
-Keywords
Constants:
Any Software is developed to handle information. This information is called
constant. Sometimes it is termed as data (raw or processed).
data = information = constant
-Integer constant
-Real constant
-Character constant
Integer Constants:
All numbers either positive or negative without decimal point are Integer
Constants.
Real Constants:
All numbers either positive or negative with decimal point involved in it are real
constant.
For example: 3.14, -43.56, 3.0 are valid Real constant.
Real constants are also known as floating point literals. A floating-point literal
has an integer part, a decimal point, a fractional part, and an exponent part. You
can represent floating point literals either in decimal form or exponential form.
While representing decimal form, you must include the decimal point, the exponent,
or both; and while representing exponential form, you must include the integer part,
the fractional part, or both. The signed exponent is introduced by e or E.
Character Constants:
All character symbols are character constants if they are enclosed in single quotes
and of unit length.
For example: ‘A’, ‘b’, ‘+’, ‘3’, ‘ ‘
There are few special characters whose length is two characters but they are treated
as single character, like ‘\n’, ‘\t’, etc.
Secondary Constants:
Secondary constants are also known as derived constants, as they are derived from
primary constants.
Arrays, strings, pointers, structures, union, enumerators are secondary constants.
Variables:
Variables are the names of memory locations where we store our data. When C++
program is under execution, operating system allocates memory to store
instructions of the program and also allocates space to store data.
Programmer has to decide how much space is required to store data. He also
specifies the names of memory locations in his program code. These names are
called variables. These locations can contain integer, real and character constants.
We can change its value according to programming requirement.
Rules for constructing variable name: