Welcome Guest | Sign in | Register
Arrays - Discussion Page For Q.10459 | C Programming Questions and Answers | C Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > Arrays > Questions and Answers

Q: What will be output when you will execute following c code?
#include
enum power{ Dalai, Vladimir=3, Barack, Hillary };
int main(){
float leader[Dalai+Hillary]={1.f,2.f,3.f,4.f,5.f};
enum power p=Barack;
printf("%0.f",leader[p>>1+1]);
return 0;
}  
A. 1 B. 2
C. 3 D. Compilation error
E. None of the above

Answer and Explanation

Answer:2

Explanation:
Size of an array can be enum constantan. Value of enum constant Barack will equal to Vladimir + 1 = 3 +1 = 4 So, value of enum variable p = 4 leader[p >> 1 +1] = leader[4 >> 1+1] =leader[4 >> 2] //+ operator enjoy higher precedence than >> operator. =leader[1] //4>>2 = (4 / (2^2) = 4/4 = 1 =2

Comment on this Question

Name:

Loading...




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.