Programming Languages C Objective
Mar 07, 2013

What will be output if you will compile and execute the following c code?

#include<stdio.h>

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;

}

Choose the correct answer:
A) Greater than
B) Equal
C) Less than
D) Compiler error
Detailed 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

Discussion (0)

No comments yet. Be the first to share your thoughts!

Share Your Thoughts
Feedback