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;
}
Discussion:
165 comments Page 15 of 17.
Ketan said:
8 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.
Bharath said:
8 years ago
Void itself is a null value. You cannot declare a null value.
Sayali said:
8 years ago
void is a return type, not a data type. Hence we can not use it to declare a variable.
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.
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.
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.
Saurav kumar roy said:
8 years ago
Void is not a keyword, it is a datatype.
Venkat said:
7 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.
The sizeof(void) it gives 1 byte.but memory not allocated so variable not declared with void.
Silpa said:
7 years ago
Hi friends, in my view, the void is a primary data type and it (void) means no return value.
Jothipriya said:
7 years ago
Void function does not return a value.
Shivkumar Hegonde said:
7 years ago
Void is not a valid data type to store the data. It should be void *.
(1)
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers