C language interview questions solution for freshers beginners placement tricky good pointers answers explanation operators data types arrays structures functions recursion preprocessors looping file handling strings switch case if else printf advance linux objective mcq faq online written test prime numbers Armstrong Fibonacci series factorial palindrome code programs examples on c++ tutorials and pdf
Far pointer questions with solution
(1) What will be output ?
void main()
{
char far *p=(char far *)0x55550005;
char far *q=(char far *)0x53332225;
clrscr();
*p=25;
(*p)++;
printf("%d",*q);
getch();
}
Output: 26
Explanation:
Far address of p and q are representing same physical address .
Physical address of 0x55550005= 0x5555*ox10+ox0005= 0x55555
Physical address of 0x53332225=0x5333*0x10+ox2225=0x55555
*p =25, means content at memory location 0x55555 is assigning value 25
(*p)++ means increase the content by one at memory location 0x5555 so now content at memory location 0x55555 is 26
*q also means content at memory location 0x55555 which is 26
(10) what will be output ?
#include
void main()
{
unsigned int i,offset_addr,seg_addr,;
char far *ptr=(char far *) 5555 FF99;
for (i=0;i<300;i++)
{
seg_addr=FP_SEG(p);
offset_addr=FP_OFF(p);
printf(“\n seg_addr %x offset_addr %x ”,seg_addr,offset_addr);
p++;
delay(100);
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment