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:
165 comments Page 6 of 17.

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

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.

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

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

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

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

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.

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

Panchanan said:   1 decade ago
Void is an generic pointer which contain any type of data. But it's size is unknown value. Before assign the void pointer value you must type converted into the required one.

void v;
int b;
b=(int)v;

Devanshmody said:   1 decade ago
Data type should be of int or one can use typedef function.


Post your comments here:

Your comments will be displayed after verification.