C Programming - Structures, Unions, Enums - Discussion
Discussion Forum : Structures, Unions, Enums - Find Output of Program (Q.No. 13)
13.
What will be the output of the program given below in 16-bit platform ?
#include<stdio.h>
int main()
{
enum value{VAL1=0, VAL2, VAL3, VAL4, VAL5} var;
printf("%d\n", sizeof(var));
return 0;
}
Discussion:
50 comments Page 4 of 5.
Prabhakar said:
2 decades ago
Value inside enum is not properly arranged then how the answer came 2. It is my doubt only.
Vignesh said:
1 decade ago
Value inside enum is not properly arranged then how the answer came 2. It is my doubt only.
Vikash said:
8 years ago
Answer will be 4 in a 32-bit compiler as the sizeof function will return the value if int.
Doyel said:
1 decade ago
In enum by default return type is int so it may be 2 or 4 byte based on compiler.
Janak said:
1 decade ago
If we had to variables had been initialised then, wat kind of o/p we would get?.
Raji said:
9 years ago
The enum is actually user defined data type consisting of integer constants.
Keerthana said:
7 years ago
Enum is an integer by default. So size will be 2bytes.
Hence the output:2.
Hence the output:2.
Sachin kakatkar said:
1 decade ago
Size of enum variable is equal the size of integer for 16-bit dos it is 2.
Keerthi said:
1 decade ago
In windows enum occupies 2 where as in linum enum occupies 4.
Kunal said:
1 decade ago
In borland c++ compiler ans is also 4...i run the program...
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers