Q.The textbook gives the following examples of declaration of variables:
int length;
float area;
char ch;
double density;
int x, y, z;
float p, q, array[25];
int length;
float area;
char ch;
double density;
int x, y, z;
float p, q, array[25];
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →[!TLDR]
All variables must be declared before use; a declaration states the data type followed by one or more comma-separated variable names and a semicolon.
The purpose of a declaration is to reserve memory of the correct size for each variable. Its syntax is:
data_type varlist;
where data_type is a basic type (int, float, char or double) and varlist is one or more variables of that type separated by commas, ending with a semicolon. In the examples, int length; reserves an integer, float area; a floating-point number, char ch; a single character and double density; a double-precision number. Several variables of the same type can be declared together, as in int x, y, z;, and an array is declared by giving its size in brackets …
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.