Discussion :: Testing sawaal
-
What will be output when you will execute following c code?
#include <stdio.h>
enum actor{
SeanPenn=5,
AlPacino=-2,
GaryOldman,
EdNorton
};
void main(){
enum actor a=0;
switch(a){
case SeanPenn: printf("Kevin Spacey");
break;
case AlPacino: printf("Paul Giamatti");
break;
case GaryOldman:printf("Donald Shuterland");
break;
case EdNorton: printf("Johnny Depp");
}
}
Answer : Option D
Explanation :
Default value of enum constant
GaryOldman = -2 +1 = -1
And default value of enum constant
EdNorton = -1 + 1 = 0
Note: Case expression can be enum constant.
Be The First To Comment