Presentation is loading. Please wait.

Presentation is loading. Please wait.

 constant represented by a name, just like a variable, but whose value cannot be changed  The const keyword precedes the type, name, and initialization.

Similar presentations


Presentation on theme: " constant represented by a name, just like a variable, but whose value cannot be changed  The const keyword precedes the type, name, and initialization."— Presentation transcript:

1

2  constant represented by a name, just like a variable, but whose value cannot be changed  The const keyword precedes the type, name, and initialization  E.g. : const int BONUS = 5000;  There are two ways for creating symbolic constants using keywords: 1. Const 2. enum  steps and rules: 1) Const must be initialized. 2) Const is local to the function where it is declared. 3) By the qualifier extern along with const, it can be made global. 4) If data type is not given it is treated as integer.

3  Variable: named storage location whose values can be manipulated during program run  Declaring a variable: as variable can be either of integer type, float or character type so its important to declare a variable having their type for identification using Data-type Declaration Statement as :  Data-type v 1, v 2...... V n  E.g. : int a;

4  There are two types of variable declaration:  Local declaration: i.e. Inside the main function  E.g.: void main() { int a, b; float x; char name[100]; }  Global decalaration : i.e. Outside the main function  E.g. : #include int a,b; float x; char name[100]; void main { ---- }

5  Variable Definition does not provide a first or initial value to a variable  Variable can be initialized in two ways: 1. At the time of variable definition: int a =10; 2. Dynamic initialization: that is during run time using expression at the place of declaration as: float avg; avg = sum/count;


Download ppt " constant represented by a name, just like a variable, but whose value cannot be changed  The const keyword precedes the type, name, and initialization."

Similar presentations


Ads by Google