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.

Atul said:   1 decade ago
Error: variable or field we is void.

Dharanesh said:   1 decade ago
As we know void is keyword not a datatype. It does return nothing.

Salunkhe amrut said:   1 decade ago
Void is return type we can declare pointer variable to void but not only variable.

Mithilesh Upadhyay said:   1 decade ago
The void is primitive data type in C. The "void" can only used as return type for function definition. It cann't used for variable declaration.

Mukesh Rai said:   1 decade ago
The "void" is used as a data type but we can not use it for variable declaration in 'C'.

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

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.

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.


Post your comments here:

Your comments will be displayed after verification.