In C, all variables must be declared before defining any executable statement in a program, but C++ allows declaration of the variables before and after executable statements.
A declaration is the process of naming of the variables and their corresponding data types in C++.
Usually , a declaration part is placed after the beginning statement and sometimes , some of the global variables can be declared outside the program.
A declaration is done by placing data type,variable name and ending with a semicolon.
The general format of the variable declaration is :
data_type identifiers1, id2,id3......,idn;
For example ,
(i)char ch;
where ch is a character data type.
(ii) short int x,y ;
where x,y are short integer data type and hold data size of 16 bits in length...
(iii) long int y;
where y is a long integer data type whose maximum size is 32 bits in length....
(iv) unsigned int limit;
where limit is a variable and it has been declared as an unsigned integer data type....
In my next post I will tell you about 'Statements', so don't miss the post on the topic very important from C++ point of view.....
Friday, June 27
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment