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 3 of 17.

Silpa said:   8 years ago
Hi friends, in my view, the void is a primary data type and it (void) means no return value.

Venkat said:   8 years ago
void is a datatype but the compiler does not allocate memory for that one.

The sizeof(void) it gives 1 byte.but memory not allocated so variable not declared with void.

Saurav kumar roy said:   8 years ago
Void is not a keyword, it is a datatype.

ISRO said:   8 years ago
Every variable needs storage in memory for storing values. Here Datatype in null, means it will not store any value. Thank you.

Asritha said:   8 years ago
The void data type is used to hold any type of variable, provided that it should be typecasted.

Here the void variable is holding int value and it's not declared/typecasted hence the compiler doesn't know what type it is and hence it raises an error.

Sayali said:   9 years ago
void is a return type, not a data type. Hence we can not use it to declare a variable.

Bharath said:   9 years ago
Void itself is a null value. You cannot declare a null value.

Ketan said:   9 years ago
The void is data type but its initialize with NULL value so no one can change or assign a value to the null variable.

Jeratin said:   9 years ago
The void is datatype.

Reema said:   9 years ago
Void is not a keyword.


Post your comments here:

Your comments will be displayed after verification.