Skip to main content
Constant With Example
- Constant
- Constants are data items that never change their value during a program execution. Their are two types of constant.A constant is something a universal value like value of pi, value of g, value of G, value of e in science.
- Types of Constant
- a) Numeric Constant
- b) String Constant
- a) Numeric Constant:-
- Numeric constants are positive or negative numbers on which mathematical operations such as addition, subtraction, multiplication and division can be formed. Some of the valid numeric constants are 150, -908, +23and 192.
Example:-
CONST pi=22/7
CONST g=9.8
- a) String Constant:-
- String constants is a set of alpha numeric or special character enclosed within double quotes (“”). Blank spaces can also be used in a string. Some of the valid string constant are “Pritam” and “Dangol”.
Example:-
CONST N$="Ramesh"
CONST place$="Kirtipur 7, Kathmandu"
Note:
Keyword is a reserved word which has fixed meaning .
Example:-
CONST for declaring constant
PRINT for displaying value in console screen
Comments
Post a Comment