Saturday, May 9, 2009

Which of the following statements allocates space for a variable of the defined enum type?

a. enum color {red, yellow, blue} paint;


b. enum color {red, yellow, blue};


c. enum { red, yellow, blue} paint;


d. both a and c

Which of the following statements allocates space for a variable of the defined enum type?
Hi !





My answer is "d. both a and c" , That's because in all the given three statements ( a , b , c) the enum definition is valid , matter of fact enum definition alone won't create memory space in memory , memory space will be allocated only if a variable is declared !


In this case options 'a' and 'c' declares enum variable and hence it get memory allocated !





Thanks and regards !


Prince M. Premnath
Reply:a, but maybe also d


No comments:

Post a Comment