Constants
Constants are the values which do no change during program execution. They are fixed. There are two type of constants.
1. Numeric constants
2. String constants
Numeric Constant:
All numbers are numeric constants. They can be whole numbers, decimal numbers, positive or a negative numbers. Following are some examples of numeric constants: 1. +23
2. -345
3. 3.456
4. -0.45
5. 5E-02(5*01-02)
6. 6.23E05(6.35*1005)
the last notation is called Scientific notation.
String constant:
String constants are framed by a group of characters which are defined in the character set. It is to be written inside double quotes (E.g. "India").It can represent name, class, day, month, address etc. Some examples are:
1. "vijay"
2. "Delhi"
3. "12"
4. "Q+W"
5. "FG-12"
The number written inside are considered as string and not numbers.
Variables:
Variables are values that change during program execution. Variables are denoted using alphabets. It is used in input statements, assignment statements etc.. Whenever we use a variable in the program, memory is allocated for it and the value is stored in that location. Whenever we access the variable the memory is accessed and used. Any changes made in it are changed
Data Types:
A data type in a programming language is a get of data with some values having predefined characteristics. For example to store whole number int is used and to store real number float is used
Following are most common data types:
Type of a variable | The value it can hold | Example of a value it can hold |
INTEGER | An integer occupies 16 bits. A whole number from -32767 to 32767. | 10 |
LONG INTEGER | long integer occupies 32 bits. A whole number, from more than -2 billion to more than 2 billion | 97,345 |
SINGLE PRESICION | single precision occupies 32 bits. A number with up to 6 digits after the decimal points. | 8.725 |
DOUBLE PRESICION | double precision occupies 64 bits. A number with up to 15 digits after the decimal point | 3.1417583294 |
STRING | String can hold text and symbols | "Suchcodes" |