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

Home > Java Programming > Pointers > Questions and Answers

Q: What will be output if you will compile and execute the following c code? 
 
#include
int main(){
char huge *p=(char *)0XC0563331;
char huge *q=(char *)0XC2551341;
if(p==q)
printf("Equal");
else if(p>q)
printf("Greater than");
else printf("Less than");
return 0;
}  
A. Equal B. Greater than
C. Less than D. Compiler error
E. None of above

Answer and Explanation

Answer:Equal

Explanation:
As we know huge pointers compare its physical address. Physical address of huge pointer p Huge address: 0XC0563331 Offset address: 0x3331 Segment address: 0XC056 Physical address= Segment address * 0X10 + Offset address =0XC056 * 0X10 +0X3331 =0XC0560 + 0X3331 =0XC3891 Physical address of huge pointer q Huge address: 0XC2551341 Offset address: 0x1341 Segment address: 0XC255 Physical address= Segment address * 0X10 + Offset address =0XC255 * 0X10 +0X1341 =0XC2550 + 0X1341 =0XC3891 Since both huge pointers p and q are pointing same physical address so if condition will true.

Comment on this Question

Name:

Loading...




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