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

Vinay Singh & Pannelal Goswami said:   1 decade ago
"Void" is no return type keyword for function use, not use in variable declaration.

Shalini k said:   1 decade ago
void doesn't return anything so instead of void if int is declared we get the result as 0.

Lalita kumari said:   10 years ago
If a variable is void and when it is printed with any datatype it accept the size and data type. So how it is wrong?

Ashitosh m n said:   10 years ago
We not declare or initialize a variable using void.

It is not possible.

Keyur vyas said:   10 years ago
It's not possible,

Because of we never declare or initialize this kind of variable using void.

Dharani Reddy said:   10 years ago
Void means null. It returns nothing.

Raviteja said:   10 years ago
It's can't void as main.

Hetram Lakhera said:   9 years ago
Hello, all.

We can not assign the value of the pointer.
but void *p;p=0;
int *i;i=0; is valid but p=1, p=9, p=67 and i=12, i=4 is not valid why?

XYZ said:   9 years ago
The void is not a data type (both primitive and non-primitive), so declaring variable 'v' with void data type leads to giving an error.

Kareem Maghawry said:   9 years ago
We never use void for declaration variables because void means nothing, so if we used void in the variable that means no variable existing and this not related to c language. But we use void in function argument declaration.


Post your comments here:

Your comments will be displayed after verification.