Constants refer to fixed values that don’t change the execution of program.
a) Numeric constants:-
Refer to a set of digits/sequel of digits.
They are 2 types.
1. Integer constants:-
They are 0 -9 proceeded by an optional + or – sign. Integers are not allowed decimal points.
Ex:- 30,15,-20,-45
2. Real constants:-
They are shown in decimal notation having whole numbers fallowed by a decimal point & the fractional port.
Ex:- 40.00, 22.33, -0.9402
b) Character constants:-
They are 2 types
1. Single :-
1. Single :-
A single character constant contains a single char enclosed in a pair of single quote marks.
Ex:- ‘a’ , ‘t’, ‘g’ , ‘,’ , ‘?’ .
2. String:-
A string constant is a sequence of character enclosed in double quotes. The characters may be letters, numbers, special characters & so on.
Ex:- “prasad” , “123”, “-+” .
Post a Comment