C Programming - Declarations and Initializations - Discussion

Discussion Forum : Declarations and Initializations - Point Out Errors (Q.No. 2)
2.
Point out the error in the following program.
#include<stdio.h>
int main()
{
    void v = 0;

    printf("%d", v);

    return 0;
}
Error: Declaration syntax error 'v' (or) Size of v is unknown or zero.
Program terminates abnormally.
No error.
None of these.
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
168 comments Page 12 of 17.

Divya said:   1 decade ago
Void returns only zero.
We cannot use it like data type only use return type.

Arpita Baheti said:   1 decade ago
For declaration of any variable required datatype variable
That is
Ex int v=0;
void is a return type not a datatype,
Therefore in this program, void v=0;.
Generates an error.

Sunil Kumar(S.K) said:   1 decade ago
Only pointer can be void not a variable.

Prasad said:   1 decade ago
Please tell me void is data type or keyword?

Lenin said:   1 decade ago
What advantage do we have declaring as a data type?

Firoz said:   1 decade ago
We must first convert it into desire data type before using it.

Vas krishna said:   1 decade ago
Because void is not a datatype. So syntaticaly its violates the declaration of a variable. So it raises compile time error.

Pavani said:   1 decade ago
We cannot declare a variable with void as data type.

DevendraSingh said:   1 decade ago
1. void is fundamental data type, which always return null(i.e void).
2. value can not be assigned to void because we cannot assign value to null, as it is already null, so it does not accept
void v = 0;
3. void is used to show return type of function only.

Rakesh kumar said:   1 decade ago
In c void means the variable we contains null value, which is not possible.


Post your comments here:

Your comments will be displayed after verification.