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.

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

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

Nivu said:   5 years ago
Thanks all for explaining.

Mallikarjunagoud said:   5 years ago
@Babi,

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.

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

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

Tharun said:   3 years ago
During declaration, we tell the datatype of the Variable.

During definition, the value is initialized.


Post your comments here:

Your comments will be displayed after verification.