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 7 of 17.
Yogeshwar Singh said:
1 decade ago
For Void there is no memory size defined for eg in 'int' data type the size is 2 byte, but for void it is not defined so we can not assign any value to void type.
MOHD JAVED SAIFE said:
1 decade ago
Void is the type of data. That tells to the user that function does not return any value. And here in the program the void is used as a variable so C language does not allow in these kinds of declaration.
Nkv said:
1 decade ago
void does not have return type.
Srividhya said:
1 decade ago
void does not return anything.
Mamatha said:
1 decade ago
Void does not contain any return value.
Vinit VJ said:
1 decade ago
void is like a 'general type' which contains nothing nor can be given/return but we can cast the variable of void type to other data type! thus we can make the same variable in exists which contains a 'memory'.
In short a data type except 'void', returns a memory space to variable in program to make it alive.
In short a data type except 'void', returns a memory space to variable in program to make it alive.
Rachna said:
1 decade ago
void should not be written here. Only this is the syntax error, otherwise it is correct. void just used for return statement and not in front of declaration.
ROSHAN MAHAJAN said:
1 decade ago
We can't used void with variables declaration. Because it is derived data type and is used for Function.
Chaitu said:
1 decade ago
Unlike other primitive data types in c, void data type does not create any variable but returns an empty set of values. Thus, we can say that it stores null.
I guess there is an error in the above program i.e., the 'A'.
Since it should not be given an integer value since it is having a null. ,
I guess there is an error in the above program i.e., the 'A'.
Since it should not be given an integer value since it is having a null. ,
Rohan said:
1 decade ago
We can't use void to declare the variables in c because void is a derived data type.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers