C Programming - Declarations and Initializations - Discussion

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

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?

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

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

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

Dhruv said:   1 decade ago
What the extern work ?

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;

Tunu said:   1 decade ago
During declaration we tell the datatype of the Variable.
During definition the value is initialized.

Naveen goud said:   1 decade ago

A declaration is just writing a type of variable or function.

a definition is simply assigning a values to that particular variable or function.

Ramarao mundru said:   1 decade ago

file f1.c
extern int a;//declaration because it doesn't allocate memory for a variable,it has allocated memory somewhere else in the program
file f2.c
int a;// it is definition because here it is getting memory

a=3;//it is assigment

Vivek patel said:   1 decade ago
Thanks to all for a good answers.

Post your comments here:

Your comments will be displayed after verification.