The pointer which can point or access whole the residence memory of RAM i.e. which can access all 16 segments is known as far pointer.
Size of far pointer is 4 byte or 32 bit. Examples:
(1) What will be output of following c program?
int main(){
int x=10;
int far *ptr;
ptr=&x;
printf("%d",sizeof ptr);
return 0;
}
Output: 4
(2)What will be output of following c program?
int main(){
int far *near*ptr;
printf("%d %d",sizeof(ptr) ,sizeof(*ptr));
return 0;
}
Output: 4 2
Explanation: ptr is far pointer while *ptr is near pointer.
(3)What will be output of following c program?
int main(){
int far *p,far *q;
printf("%d %d",sizeof(p) ,sizeof(q));
}
Output: 4 4
First 16 bit stores: Segment number
Next 16 bit stores: Offset address
Example:
int main(){
int x=100;
int far *ptr;
ptr=&x;
printf("%Fp",ptr);
return 0;
}
Output: 8FD8:FFF4
Here 8FD8 is segment address and FFF4 is offset address in hexadecimal number format.
Note: %Fp is used for print offset and segment address of pointer in printf function in hexadecimal number format.
In the header file dos.h there are three macro functions to get the offset address and segment address from far pointer and vice versa.
1. FP_OFF(): To get offset address from far address.
2. FP_SEG(): To get segment address from far address.
3. MK_FP(): To make far address from segment and offset address.
Examples:
(1)What will be output of following c program?
#include "dos.h"
int main(){
int i=25;
int far*ptr=&i;
printf("%X %X",FP_SEG(ptr),FP_OFF(ptr));
}
Output: Any segment and offset address in hexadecimal number format respectively.
(2)What will be output of following c program?
#include "dos.h"
int main(){
int i=25;
int far*ptr=&i;
unsigned int s,o;
s=FP_SEG(ptr);
o=FP_OFF(ptr);
printf("%Fp",MK_FP(s,o));
return 0;
}
Output: 8FD9:FFF4 (Assume)
Note: We cannot guess what will be offset address; segment address and far address of any far pointer .These address are decided by operating system.
Limitation of far pointer:
We cannot change or modify the segment address of given far address by applying any arithmetic operation on it. That is by using arithmetic operator we cannot jump from one segment to other segment. If you will increment the far address beyond the maximum value of its offset address instead of incrementing segment address it will repeat its offset address in cyclic order.
Example:
(q)What will be output of following c program?
int main(){
int i;
char far *ptr=(char *)0xB800FFFA;
for(i=0;i<=10;i++){
printf("%Fp \n",ptr);
ptr++;
}
return 0;
}
Output:
B800:FFFA
B800:FFFB
B800:FFFC
B800:FFFD
B800:FFFE
B800:FFFF
B800:0000
B800:0001
B800:0002
B800:0003
B800:0004
This property of far pointer is called cyclic nature of far pointer within same segment.
Important points about far pointer:
1. Far pointer compares both offset address and segment address with relational operators.
Examples:
(1)What will be output of following c program?
int main(){
int far *p=(int *)0X70230000;
int far *q=(int *)0XB0210000;
if(p==q)
printf("Both pointers are equal");
else
printf("Both pointers are not equal");
return 0;
}
Output: Both pointers are not equal
(2)What will be output of following c program?
int main(){
int far *p=(int *)0X70230000;
int far *q=(int *)0XB0210000;
int near *x,near*y;
x=(int near *)p;
y=(int near *)q;
if(x==y)
printf("Both pointer are equal");
else
printf("Both pointer are not equal");
return 0;
}
Output: Both pointers are equal
2. Far pointer doesn’t normalize.
237 comments:
«Oldest ‹Older 201 – 237 of 237int main(){
int num,i=0;
do{
printf("To enter press 1\n");
printf("To exit press 2");
scanf("%d",&num);
++i;
switch(num){
case 1:printf("You are welcome\n");break;
default : exit(0);
}
}
while(i<=10);
return 0;
}
Output: 3 3 4 4
question no 8
how come output is this??
this is wrong
we r not printing any value
Programming in c by Stephen kochain and expert in c
You can also refer numerical recipes inc
Nice site and nice ques
Plz upload some more questions
wow.......this is helpfull blog.....
I can't understand the meaning for third questions answer.Can u please explain me....?
It's great job and more useful to others
Hello there!
I'm Simran from Receptix - a job search portal. I stumbled on your website and I must say it envelopes great information.
Coincidentally, we have a video designed on a topic similar to your blog post on interview questions on C language. I was wondering that incorporating this video can further enhance the user experience on your page. Here's the link to the video
https://www.youtube.com/watch?v=WPnURgypr9U
It will be great if you could also mention www.receptix.com as the source, along with the video.
Look forward to this content synergy.
Thanks
Thank for this blog are more informative step by step and useful contents. I here by attached my site would you see this blog
7 tips to start a career in digital marketing
“Digital marketing is the marketing of product or service using digital technologies, mainly on the Internet, but also including mobile phones, display advertising, and any other digital medium”. This is the definition that you would get when you search for the term “Digital marketing” in google. Let’s give out a simpler explanation by saying, “the form of marketing, using the internet and technologies like phones, computer etc”.
we have offered to the advanced syllabus course digital marketing for available join now
more details click the link now
https://www.webdschool.com/web-development-course-in-chennai.html
Amazing blog useful information
Web designing trends in 2020
When we look into the trends, everything which is ruling today’s world was once a start up and slowly begun getting into. But Now they have literally transformed our lives on a tremendous note. To name a few, Facebook, Whats App, Twitter can be a promising proof for such a transformation and have a true impact on the digital world.
we have offered to the advanced syllabus course web design and development for available join now
more details click the link now
https://www.webdschool.com/web-development-course-in-chennai.html
Great good questions keep it up
Learnprogramo.
Excellent Blog! I would like to thank for the efforts you have made in writing this post. I am hoping the same best work from you in the future as well. I wanted to thank you for this websites! Thanks for sharing. Great websites! 360DigiTMG PMP Certification
PMP Certification in Malaysia
PMP Course
PMP Course in Malaysia
I was just browsing through the internet looking for some information and came across your blog. I am impressed by the information that you have on this blog. It shows how well you understand this subject. Bookmarked this page, will come back for more.
360DigiTMG PMP Certification
360DigiTMG PMP Course in malaysia
360DigiTMG PMP Course
360DigiTMG PMP Training in malaysia
360DigiTMG PMP Training
Awesome blog. I enjoyed reading your articles. This is truly a great read for me. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work!
data analytics course
big data analytics malaysia
big data course
It was a great information and Its really worth reading it.
Online Training
software training institute
online classes
Amazing blog with unique information found valuable and enjoyed reading this one. Keep posting. Thanks for sharing.
Data Science Training in Hyderabad
Mua vé máy bay tại đại lý Aivivu, tham khảo
giá vé máy bay đi Mỹ khứ hồi
vé máy bay từ mỹ về việt nam hãng eva
lịch bay hà nội nha trang
giá vé máy bay sài gòn - phú quốc
vé máy bay đi huế vietnam airlines
This is so helpful, thanks for the detailed explanation. You could find more question on C from here
I feel very grateful that I read this. It is very helpful and very informative and I really learned a lot from it.
Data Science Course in Chennai
Great work sir Thank you
for more at https://www.trickcode.in/
You have completed certain reliable points there. I did some research on the subject and found that almost everyone will agree with your blog.
Data Science Training in Bangalore
I am more curious to take an interest in some of them. I hope you will provide more information on these topics in your next articles.
Machine Learning Course in Bangalore
I am happy to visit your blog, a lot of things I can take the benefits of each of your articles. thank you
wordpress
ufa88kh.blogspot
youtube
casino online in cambodia
I was browsing the internet for information and found your blog. I am impressed with the information you have on this blog.
MLOps Course
Extraordinary post I should state and a debt of gratitude is in order for the data. Instruction is unquestionably a clingy subject. Be that as it may, is still among the main subjects within recent memory. I value your post and anticipate more. artificial intelligence course in lucknow
Excellent Blog! I would like to thank for the efforts you have made in writing this post. I am hoping the same best work from you in the future as well. I wanted to thank you for this websites! Thanks for sharing. Great websites!data analytics course in nagpur
I feel very grateful that I read this. It is very helpful and very informative and I really learned a lot from it.<a href="https://360digitmg.com/india/cloud-computing-course-in-jaipur>cloud computing course in jaipur</a>
I am looking for and I love to post a comment that "The content of your post is awesome" Great work! Business Analytics Course in Vadodara
This is really nice which is really cool blog and you have really helped a lot of people who visit the blog and give them useful information.
Data Science Training in Noida
The blog is informative and very useful therefore, I would like to thank you for your effort in writing this article.
Data Analytics Course in Lucknow
thanks for sharing nice article visit Best Java Programming Tutorials and Courses
Really, this article is truly one of the best in the article. And this one that I found quite fascinating and should be part of my collection. Very good work!.
Data Science Training in Jaipur
I appreciate you giving such lovely content. I learned something from your blog. Continue sharing.
lawyers for bankruptcy near me
Hi.
Thank you for sharing this information with us. This blog was great thanks for giving this information about c language and it uses and we learn some new things in this blog thanks for Sharing this information with us
Here is sharing some Oracle Project Accounting information may be its helpful to you.
Oracle Project Accounting Training
informative blog, your blog help me alot to undrestand this things in easy way, i too have some informative article here reactjs classes in pune
Post a Comment