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 1 of 4.

Tharun said:   1 year ago
During declaration, we tell the datatype of the Variable.

During definition, the value is initialized.

Sakshi wadhwa said:   3 years ago
Why float square(float x) is not a declaration? Please explain.

Masanta said:   3 years ago
Thank you all for explaining it.

Mallikarjunagoud said:   3 years ago

For a variable, declaration means just stating its data type along with giving it name for memory allocation; while definition means giving the value of that variable. The declaration is giving a prototype like simply a name. The definition is associating the task or the meaning with the prototype.

Nivu said:   4 years ago
Thanks all for explaining.

Prachi said:   4 years ago
The semicolon is not used in the function definition.

Aisha said:   5 years ago
Can you give an eg for initialization and explanation for output?

Vani said:   6 years ago
Nice explanation @Sundar.

Priyanka garg said:   6 years ago
double pow(double,double);

Is it not the function call?

San said:   7 years ago
If pow is the functional means then what about pow?

Is it also expanded as the power of right? Do clearly explain anyone?

Post your comments here:

Your comments will be displayed after verification.