C Programming - Declarations and Initializations - Discussion

Discussion Forum : Declarations and Initializations - General Questions (Q.No. 9)
9.
Identify which of the following are declarations
1 : extern int x;
2 : float square ( float x ) { ... }
3 : double pow(double, double);
1
2
1 and 3
3
Answer: Option
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.
Discussion:
37 comments Page 4 of 4.

Sravya said:   1 decade ago
@ aishu:
declaration just assigns a data type for the variable taken..
ex: int x;
whereas definition assigns a value satisfying the data type
ex: int x=2;

Dhruv said:   1 decade ago
What the extern work ?

@ deepti: said:   1 decade ago
What are string? how are they declared? and what is the null character ?why is it important?

Vijay said:   1 decade ago
What is difference between declaration and definition?

Prabhu said:   1 decade ago
Declaration never reserves any space for the variable or instance in the program's memory.

Santosh kumar said:   1 decade ago
float square ( float x ) { ... } but here it is declared and as well as can be defined so why cant we put it in the category of declaration. it comes under both declaration and definition, can any one explain me in detail?

Bhoopend said:   1 decade ago
float square(float x) {...} is both dec/def because in prototype square(float) does not reserve any space in memory as we declare square(float x) now it reserve memory for float variable x.


Post your comments here:

Your comments will be displayed after verification.