Let Us C
Fourteenth Edition
Yashavant Kanetkar
i
Dedicated to baba
Who couldn’t be here to see this day...
ii
About the Author
Through his books and Quest Video Courseware DVDs on C, C++, Data
Structures, VC++, .NET, Embedded Systems, etc. Yashavant Kanetkar has
created, moulded and groomed lacs of IT careers in the last two
decades. Yashavant’s books and Quest DVDs have made a significant
contribution in creating top-notch IT manpower in India and abroad.
Yashavant’s books are globally recognized and millions of students /
professionals have benefitted from them. Yashavant's books have been
translated into Hindi, Gujarati, Japanese, Korean and Chinese languages.
Many of his books are published in India, USA, Japan, Singapore, Korea
and China.
Yashavant is a much sought after speaker in the IT field and has
conducted seminars/workshops at TedEx, IITs, RECs and global software
companies.
Yashavant has recently been honored with the prestigious
“Distinguished Alumnus Award” by IIT Kanpur for his entrepreneurial,
professional and academic excellence. This award was given to top 50
alumni of IIT Kanpur who have made significant contribution towards
their profession and betterment of society in the last 50 years.
In recognition of his immense contribution to IT education in India, he
has been awarded the "Best .NET Technical Contributor" and "Most
Valuable Professional" awards by Microsoft for 5 successive years.
Yashavant holds a BE from VJTI Mumbai and M.Tech. from IIT
Kanpur.
iii
Acknowledgments
Let Us C has become an important part of my life. I have created and
nurtured it for last decade and half. While doing so, I have received, in
addition to the compliments, a lot of suggestions from students,
developers, professors, publishers and authors. So much have their
inputs helped me in taking this book up to its fourteenth edition that
ideally I should put their names too on the cover page.
In particular, I am indebted to Manish Jain who had a faith in this book
idea, believed in my writing ability, whispered the words of
encouragement and made helpful suggestions from time to time. I hope
every author gets a publisher who is as cooperative, knowledgeable and
supportive as Manish.
The Fourteen editions of this book saw several changes and facelifts.
During this course many people helped in executing programs and
spotting bugs. I trust that with their collective acumen, all the programs
in this book would run correctly. I value the work that they did a lot. Any
errors, omissions or inconsistencies that remain are, alas, my
responsibility.
I thank Dada, Ammi—my parents, Seema—my wife, Aditya, Anuj—my
sons for enduring the late nights, the clicking keyboard, and mostly for
putting up with yet another marathon book effort.
Thinking of a book cover idea is one thing, putting it into action is a
different cup of tea. This edition’s cover idea has been implemented by
Jayant. Many thanks to him.
And finally my heartfelt gratitude to the countless students who made
me look into every nook and cranny of C. I want to remain in their debt.
It is only because of them that Let Us C is now published from India,
Singapore, USA, Japan, Korea and China in multiple languages.
iv
Preface
In this I have reorganized the contents of the book in a major way. After
going through the thirteenth edition several times I decided to realign all
the chapters in such a manner that if a C programming course is taught
using Let Us C, it can roughly be finished in 23 lectures of one hour each,
with one chapter's contents devoted to one lecture. I hope this would
make the learning path trouble-free. Some end-of-chapter exercises in
the book needed a second look to make them more practical. That also
stands done now.
Many readers told me that they have immensely benefitted from the
inclusion of the chapter on Interview FAQs. I have improved this chapter
further. The rationale behind this chapter is simple—ultimately all the
readers of Let Us C sooner or later end up in an interview room where
they are required to take questions on C programming. I now have a
proof that this chapter has helped to make that journey smooth and
fruitful.
All the programs present in the book are available in source code form
at www.kicit.com/books/letusc/sourcecode. You are free to download
them, improve them, change them, do whatever with them. If you wish
to get solutions for the Exercises in the book they are available in
another book titled ‘Let Us C Solutions’. If you want some more
problems for practice they are available in the book titled ‘Let Us C
Workbook’. As usual, new editions of these two books have also been
launched along with 14th edition of Let Us C.
If you like ‘Let Us C’ and want to hear the complete video-recorded
lectures created by me on C language (and other subjects like C++, VC++,
C#, Java, .NET, Embedded Systems, etc.), then you can visit
http://quest.ksetindia.com for more details.
‘Let Us C’ is as much your book as it is mine. So if you feel that I could
have done certain job better than what I have, or you have any
suggestions about what you would like to see in the next edition, please
drop a line to [email protected].
Countless Indians have relentlessly worked for close to two decades to
successfully establish “India” as a software brand. At times, I take secret
pleasure in seeing that a Let Us C has contributed in its own little way in
shaping so many careers that have made the “India” brand acceptable.
v
Recently I was presented with “Distinguished Alumnus Award” by IIT
Kanpur. It was great to figure in a list that contained Narayan Murthy,
Chief Mentor, Infosys, Dr. D. Subbarao, former Governor, Reserve Bank
of India, Dr. Rajeev Motwani of Stanford University, Prof. H. C. Verma,
Mr. Som Mittal President of NASSCOM, Prof. Minwalla of Harvard
University, Dr. Sanjay Dhande former Director of IIT Kanpur, Prof. Arvind
and Prof. Sur of MIT USA and Prof. Ashok Jhunjhunwala of IIT Chennai.
I think Let Us C amongst my other books has been primarily responsible
for helping me get the “Distinguished Alumnus” award. What was a bit
surprising was that almost all who were present knew about the book
already and wanted to know from me what it takes to write a book that
sells in millions of copies. My reply was—make an honest effort to make
the reader understand what you have to say and keep it simple. I don’t
know how convincing was this answer, but well, that is what I have been
doing with this book in all its previous thirteen editions. I have followed
the same principle with this edition too.
All the best and happy programming!
Yashavant Kanetkar
vi