# C Programming - Declarations and Initializations

### Exercise :: Declarations and Initializations - General Questions

6.

By default a real number is treated as a

 A. float B. double C. long double D. far double

Explanation:

In computing, 'real number' often refers to non-complex floating-point numbers. It include both rational numbers, such as 42 and 3/4, and irrational numbers such as pi = 3.14159265...

When the accuracy of the floating point number is insufficient, we can use the double to define the number. The double is same as float but with longer precision and takes double space (8 bytes) than float.

To extend the precision further we can use long double which occupies 10 bytes of memory space.

7.

Which of the following is not user defined data type?
 1 : ``````struct book { char name; float price; int pages; };`````` 2 : ``long int l = 2.35;`` 3 : ``enum day {Sun, Mon, Tue, Wed};``

 A. 1 B. 2 C. 3 D. Both 1 and 2

Explanation:

C data types classification are

1. Primary data types
1. int
2. char
3. float
4. double
5. void
2. Secondary data types (or) User-defined data type
1. Array
2. Pointer
3. Structure
4. Union
5. Enum

So, clearly long int l = 2.35; is not User-defined data type.
(i.e.long int l = 2.35; is the answer.)

8.

Is the following statement a declaration or definition?
extern int i;

 A. Declaration B. Definition C. Function D. Error

Explanation:

Declaring is the way a programmer tells the compiler to expect a particular type, be it a variable, class/struct/union type, a function type (prototype) or a particular object instance. (ie. extern int i)

Declaration never reserves any space for the variable or instance in the program's memory; it simply a "hint" to the compiler that a use of the variable or instance is expected in the program. This hinting is technically called "forward reference".

9.

Identify which of the following are declarations
 1 : extern int x; 2 : float square ( float x ) { ... } 3 : double pow(double, double);

 A. 1 B. 2 C. 1 and 3 D. 3

Explanation:

extern int x; - is an external variable declaration.

double pow(double, double); - is a function prototype declaration.

Therefore, 1 and 3 are declarations. 2 is definition.

10.

In the following program where is the variable a getting defined and where it is getting declared?

``````#include<stdio.h>
int main()
{
extern int a;
printf("%d\n", a);
return 0;
}
int a=20;
``````

 A. extern int a is declaration, int a = 20 is the definition B. int a = 20 is declaration, extern int a is the definition C. int a = 20 is definition, a is not defined D. a is declared, a is not defined

Explanation:

- During declaration we tell the datatype of the Variable.

- During definition the value is initialized.