Welcome Guest | Sign in | Register
Arrays - Discussion Page For Q.10417 | 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?
aaa()
{
printf("hi");
}
bbb(){
printf("hello");
}
ccc(){
printf("bye");
}
main()
{
int (*ptr[3])();
ptr[0]=aaa;
ptr[1]=bbb;
ptr[2]=ccc;
ptr[2]();
}
A. hi hello bye B. bye
C. hi D. None of these

Answer and Explanation

Answer:bye

Explanation:
ptr is array of pointers to functions of return type int.ptr[0] is assigned to address of the function aaa. Similarly ptr[1] and ptr[2] for bbb and ccc respectively. ptr[2]() is in effect of writing ccc(), since ptr[2] points to ccc.

Comment on this Question

Name:

Loading...




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