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

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

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.

Lipsha said:   1 decade ago
What is the difference between actual definition & formal definition?

Priyanka said:   1 decade ago
Hi Lipsha,

void main()
{
int num1;
display(num1);
}

void display(int para1)

{
-----------
-----------
}

In This example:

-> num1 is actual definition or actual parameter.(Parameters used in Function declaration is called actual parameters.).

-> para1 is formal definition or formal parameters.(Parameters used in Function definition is called actual parameters.).


Post your comments here:

Your comments will be displayed after verification.