Programming in C 1st Edition - eBook PDF download
Programming in C 1st Edition - eBook PDF download
download
https://ebookluna.com/download/programming-in-c-ebook-pdf/
https://ebookluna.com/download/programming-in-ansi-c-ebook-pdf/
Readings from Programming with C++ 1st Edition Kyla Mcmullen - eBook PDF
https://ebookluna.com/download/readings-from-programming-with-c-ebook-
pdf-2/
Readings from Programming with C++ 1st Edition Kyla Mcmullen - eBook PDF
https://ebookluna.com/download/readings-from-programming-with-c-ebook-pdf/
https://ebookluna.com/product/ebook-pdf-murachs-c-programming-by-joel-
murach/
C++ Programming 8th ed Edition D. S - eBook PDF
https://ebookluna.com/download/c-programming-ebook-pdf/
https://ebookluna.com/product/ebook-pdf-programming-problem-solving-and-
abstraction-with-c/
Programming With STM32: Getting Started With the Nucleo Board and C/C++ -
eBook PDF
https://ebookluna.com/download/programming-with-stm32-getting-started-with-
the-nucleo-board-and-c-c-ebook-pdf/
https://ebookluna.com/download/c-programming-an-object-oriented-
approach-1e-ise-ebook-pdf/
https://ebookluna.com/product/ebook-pdf-fundamentals-of-c-programming-for-
information-systems-2nd-edition/
Programming in C
About the Author
E Balagurusamy, is presently the Chairman of EBG Foundation, Coimbatore. In the past he has also
held the positions of member, Union Public Service Commission, New Delhi and Vice-Chancellor, Anna
University, Chennai. He is a teacher, trainer and consultant in the fields of Information Technology
and Management. He holds an ME (Hons) in Electrical Engineering and PhD in Systems Engineering
from the Indian Institute of Technology, Roorkee. His areas of interest include Object-Oriented Software
Engineering, E-Governance: Technology Management, Business Process Re-engineering and Total
Quality Management.
A prolific writer, he has authored a large number of research papers and several books. His best-selling
books, among others include:
∑ Fundamentals of Computers
∑ Computing Fundamentals and C Programming, 2e
∑ Programming in C#, 3/e
∑ Programming in Java, 5/e
∑ Object-Oriented Programming with C++, 7/e
∑ Numerical Methods
∑ Reliability Engineering
A recipient of numerous honors and awards, he has been listed in the Directory of Who's Who of
Intellectuals and in the Directory of Distinguished Leaders in Education.
Programming in C
E Balagurusamy
Chairman
EBG Foundation
Coimbatore
Programming in C
Copyright © 2018, by McGraw Hill Education (India) Private Limited. No part of this publication may be repro-
duced or distributed in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise
or stored in a database or retrieval system without the prior written permission of the publishers. The program
listings (if any) may be entered, stored and executed in a computer system, but they may not be reproduced for
publication.
ISBN-13: 978-93-87432-36-9
ISBN-10: 93-87432-36-X
1 23456789 D101417 22 21 20 19 18
Printed and bound in India.
Managing Director: Kaushik Bellani
Director—Science & Engineering Portfolio: Vibha Mahajan
Senior Portfolio Manager—Science & Engineering: Hemant K Jha
Associate Portfolio Manager—Science & Engineering: Mohammad Salman Khurshid
Production Head: Satinder S Baveja
Assistant Manager—Production: Anuj K Shriwastava
General Manager—Production: Rajender P Ghansela
Manager—Production: Reji Kumar
Information contained in this work has been obtained by McGraw Hill Education (India), from sources believed
to be reliable. However, neither McGraw Hill Education (India) nor its authors guarantee the accuracy or
completeness of any information published herein, and neither McGraw Hill Education (India) nor its authors
shall be responsible for any errors, omissions, or damages arising out of use of this information. This work is
published with the understanding that McGraw Hill Education (India) and its authors are supplying information
but are not attempting to render engineering or other professional services. If such services are required, the
assistance of an appropriate professional should be sought.
Typeset at The Composers, 260, C.A. Apt., Paschim Vihar, New Delhi 110 063 and printed at
Preface xiii
Constants 27
Variables 31
Data Types 32
Declaration of Variables 35
Declaration of Storage Class 38
Assigning Values to Variables 39
Defining Symbolic Constants 44
Declaring a Variable as Constant 46
Declaring a Variable as Volatile 46
Key Concepts 46
Always Remember 47
Brief Cases 47
Review Questions 50
Debugging Exercises 51
Programming Exercises 52
UNIT 4: sTrUcTUrEs
12. Structures and Unions 381
Introduction 381
Defining a Structure 382
Declaring Structure Variables 383
Accessing Structure Members 385
Contents xi
Annexure 1: Model Question Papers with Hints and Short Solutions 473
annexure 2: Developing a c Program: some guidelines 492
Appendix I: Bit-Level Programming 507
appendix II: ascII Values of characters 512
Appendix III: ANSI C Library Functions 514
Preface
C
is a powerful, flexible, portable and elegantly structured programming language. Since C
combines the features of high-level language with the elements of the assembler, it is suitable
for both systems and applications programming. It is undoubtedly the most widely used general-
purpose language today in operating systems, and embedded system development. Its influence
is evident in almost all modern programming languages. Since its standardization in 1989, C has
undergone a series of changes and improvements in order to enhance the usefulness of the language.
The version that incorporates the new features is now referred to as C11.
Digital supplements
The digital supplement can be accessed at the given link (http://www.mhhe.com/balagurusamy/picau17)
It contains the following components:
∑ Write up on Self Referential Structures
∑ Write up on Selection sort, linear and binary search
∑ Additional Programs for practice
xiv Preface
feedback
I welcome any constructive criticism of the book and will be grateful for any appraisal by the readers.
Feedback to improve the book will be highly appreciated.
E Balagurusamy
Publisher’s Note
McGraw Hill Education (India) invites suggestions and comments from you, all of which can be sent
to [email protected] (kindly mention the title and author name in the subject line). Piracy-
related issues may also be reported.
UNIT 1
Basics of C Programming
Chapter 1 Overview of C
Chapter 2 Constants, Variables and Data Types
Chapter 3 Operators and Expressions
Chapter 4 Managing Input and Output Operations
Chapter 5 Decision Making and Branching
Chapter 6 Decision Making and Looping
Chapter 7 The Preprocessor
Another Random Scribd Document
with Unrelated Content
[16] One should almost suppose that the historian had recollected
Cyrano de Bergerac's dream of a visit to the infernal regions,
where he saw the Duke of Clarence, "who," says he, "voluntarily
drowned himself in a barrel of Malmsey, seeking for Diogenes, in
hopes of getting half his tub to lodge in."
KING HENRY VI.
PART III.
ACT I.
Scene 1. Page 223.
Exe. Here comes the queen whose looks bewray her
anger.
Although the word bewray has received very proper illustration on
the present and other occasions, it remains to observe that its
simple and original meaning was to discover or disclose; that it has
been confounded with betray, which is used, though not exclusively,
for to discover for bad or treacherous purposes, a sense in which
bewray is never properly found. Of this position take the following
proof: "If you do so, saide the other, then you ought to let me
knowe what so ever you know your selfe: unlesse you thinke that
yourself will bewray yourself, except you doubt yourself will deceive
yourself, and unlesse you thinke that yourself will betray your self."—
Lupton's Siuqila, 1580, 4to, sign. L 4. b.
Scene 1. Page 224.
Q. Mar. Rather than made that savage duke thine heir.
The note which follows Mr. Steevens's was not inadvertently
introduced by that gentleman, though it certainly should not have
been retained as the text now stands.
Scene 4. Page 242.
Q. Mar. [Putting a paper crown on his head.]
Mr. Ritson has not shown, as he conceived he had, that the
preceding commentator was certainly mistaken: for the author of the
play, if he be accountable for the stage direction, could not have
"followed history with the utmost precision," when he makes queen
Margaret put a paper crown on York's head; whereas Holinshed, the
black-letter chronicler whom Mr. Ritson should have first consulted,
and who only follows Whethamstede, relates that a garland of
bulrushes was placed on York's head; which was afterwards stricken
off and presented to the queen. Nor is there historical evidence that
the queen herself put on the crown. Shakspeare has continued the
same error in King Richard the Third, where he makes Gloucester
say to queen Margaret,
ACT III.
Scene 2. Page 310.
ACT IV.
Scene 7. Page 359.
Glo. For many men that stumble at the threshold.
To understand this phrase rightly, it must be remembered that some
of the old thresholds or steps under the door, were, like the hearths,
raised a little, so that a person might stumble over them unless
proper care was taken. A very whimsical reason for this practice is
given in a curious little tract by Sir Balthazar Gerbier, entitled,
Councel and advice to all builders, 1663, 24mo, in these words, "A
good surveyour shuns also the ordering of doores with stumbling-
block-thresholds, though our forefathers affected them, perchance to
perpetuate the antient custome of bridegroomes, when formerly at
their return from church [they] did use to lift up their bride, and to
knock their head against that of the doore, for a remembrance, that
they were not to passe the threshold of their house without their
leave."
ACT V.
Scene 7. Page 403.
The question with Dr. Johnson is, whether it be war that capers, or
York; and he justly remarks that if the latter, the antecedent is at an
almost forgotten distance. The amorous temper of Edward the
Fourth is well known; and there cannot be a doubt that by the
lascivious pleasing of a lute, he is directly alluded to. The
subsequent description likewise that Richard gives of himself is in
comparison with the king. Dr. Johnson thought the image of war
capering poetical; yet it is not easy to conceive how grimvisag'd war
could caper in a lady's chamber.
Scene 1. Page 462.
Glo. Cheated of feature by dissembling nature.
The poet by this expression seems to mean no more than that
nature had made for Richard features unlike those of other men. To
dissemble, both here and in the passage quoted from King John,
signifies the reverse of to resemble, in its active sense, and is not
used as dissimulare in Latin.
ACT II.
Scene 3. Page 540.
2 Cit. Ill news by'r lady; seldom comes the better.
Well might the author of the book quoted by Mr. Reed say "that
proverb indeed is auncient," as will appear from the following
curious account of its origin extracted from a manuscript collection
of stories compiled about the time of king Henry the Third:—
"Quidam abbas dedit monachis suis tria fercula. Dixerunt monachi,
Iste parum dat nobis. Rogemus Deum ut cito moriatur. Et sive ex hac
causa, sive ex alia, mortuus est. Substitutus est alius, qui eis tamen
dedit duo fercula. Irati monachi contristati dixerunt, Nunc magis est
orandum, quia unum ferculum subtractum est, Deus subtrahat ei
vitam suam. Tandem mortuus est. Substitutus est tertius, qui duo
fercula subtraxit. Irati monachi dixerunt, Iste pessimus est inter
omnes, quia fame nos interficit; rogemus Deum quod cito moriatur.
Dixit unus monachus, Rogo Deum quod det ei vitam longam, et
manu teneat eum nobis. Alii admirati querebant quare hoc diceret;
qui ait, Vide quod primus fuit malus, secundus pejor, iste pessimus;
timeo quod cum mortuus fuerit alius pejor succedet, qui penitus nos
fame perimet. Unde solet dici, Seilde comed se betere."
Scene 4. Page 546.
Q. Eliz. A parlous boy.
"Parlous," says Mr. Steevens, "is keen, shrewd." Mr. Ritson is of a
different opinion, and thinks it a corruption of perilous, dangerous.
Both parties are right; but it is probably used here as perilous, in like
manner as the nurse in Romeo and Juliet talks of "a parlous knock,"
and as it is also to be taken in A midsummer night's dream, where
Mr. Steevens had properly explained it; and the instance which he
has given on the present occasion does, in fact, corroborate his
former note. Parlous is likewise made synonymous with shrewd by
Littelton. See his Latin dict. v. importunus. In Middleton's play of The
changeling, we have "a parlous fool," i. e. shrewd, "he must sit in
the fourth form at least." Yet a few pages further the same word is
as clearly used for perilous. After all there is little or no difference in
the senses of it, for in shrewdness there is certainly peril. He that
meets with a shrew, may well be said to be in danger. Some might
think that this word is the same as talkative, in which case it must
have been borrowed from the French; but that language does not
furnish an adjective of the kind. The original corruption was perlious.
Thus in an unpublished work by William of Nassyngton, a poet of the
fifteenth century, who wrote on the Lord's prayer, &c., we have,
"Methinks this maner is perlious."
ACT III.
Scene 1. Page 561.
ACT IV.
Scene 2. Page 621.
K. Rich. Because that like a Jack, thou keep'st the
stroke.
At Horsham church, in Sussex, there was a figure dressed in scarlet
and gold, that struck the quarters. He was called Jack o' the clock-
house. The French term for this kind of automaton is jaquemar, the
etymology of which is very fanciful and uncertain.
ACT V.
Scene 1. Page 660.
Buck. Holy king Henry——
This epithet is not applied without good reason. King Henry the
Sixth, though never actually canonized, was regarded as a saint, and
miracles were supposed to have been performed by him. In some of
our church service-books before the Reformation, there are prayers
which are said to have been of his composition, and one in particular
that is addressed to him is entitled, "A prayer to holy king Henry."
Scene 3. Page 665.
K. Rich. Besides, the king's name is a tower of
strength.
Borrowed from Proverbs, xviii. v. 10. "The name of the Lord is a
strong tower."
Scene 3. Page 667.
"A supper at so late an hour as nine o'clock in the year 1485," says
Mr. Steevens, "would have been a prodigy." It certainly would, and
even at the time when this play was written, the period to which the
criticism more justly belongs. In either instance there was a reason
for preferring the text of the quarto copy, and yet the unnecessary
alteration is retained.
Scene 3. Page 688.
K. Rich. This and Saint George to boot.
Dr. Johnson is undoubtedly right against both his opponents, one of
whom has adduced the phrase St. George to borrow, unintentionally
in support of him. To borrow is no more a verb than to boot; it
means as a pledge or security, borrow being the Saxon term for a
pledge. The phrase is an invocation to the saint to act as a protector.
Saint George to thrive is evidently a misconceived paraphrase of the
old mode of expression, by improperly changing the substantive to a
verb. Holinshed, in the speech of Richard before the battle,
introduces "St. George to borrowe."
Scene 3. Page 690.
K. Rich. Long kept in Bretagne at our mother's cost.
It has already been stated by Dr. Farmer that the mistake here of
mother for brother must be placed to the account of the book which
Shakspeare followed, viz. Holinshed's chronicle; but the doctor has
omitted to notice that in the first edition of Holinshed the word is
rightly printed brother. It is no otherwise worth while to mention this
fact, than that it points out the particular edition of the above
historian which Shakspeare used. Nothing can be more judicious nor
decisive than Mr. Malone's argument for retaining the historical
errors of Shakspeare, and Mr. Ritson's desire of changing the text
does not correspond with those principles of accuracy on which he
laid so much stress.
Scene 3. Page 691.
K. Rich. A milksop, &c.
This is from Holinshed, "To begyn with the earle of Richmonde
capitayne of this rebellion, he is a Welsh milksoppe," &c.
FOOTNOTES:
[17] See the fine frontispiece by Coriolano to Vesalius's Anatomy.
KING HENRY VIII.
ACT I.
Scene 1. Page 21.
ACT II.
Scene 2. Page 71.
Nor. I'll venture one heave at him.
The first folio reads "I'll venture one; have at him," and this, except
as to the punctuation, is right. Have at you was a common phrase; it
is used by Surrey in the ensuing act, and afterwards by Cromwell.
Scene 2. Page 73.
This is from Holinshed. "Aboute this time the king received into favor
doctor Stephen Gardiner, whose service he used in matters of great
secrecie and weighte, admitting him in the room of Doctor Pace, the
which being continually abrode in ambassades, and the same
oftentymes not much necessarie, by the Cardinalles appointment, at
length he toke such greefe therwith, that he fell out of his right
wittes."
Scene 3. Page 75.
ACT III.
Scene 2. Page 112.
Both these charges seem included in the third article. "Also the said
Lord Cardinall being your ambassador in France, sent a commission
to Sir Gregory de Cassalis under your great seale in your grace's
name to conclude a treaty of amity with the Duke of Ferrara, without
any commandment or warrant of your highnes, nor your said
highnesse advertised or made privy to the same."
Scene 2. Page 129.
ACT V.
Scene 3. Page 193.
Man. ... and hit that woman, who cry'd out, Clubs!
It has been observed, in illustration of this practice of crying out
clubs, that it was usually adopted in any quarrel or tumult in the
streets; but it remains to point out the persons that were so called,
because the watchmen's weapon was the bill. Stowe informs us, that
"when prentizes and journeymen attended upon their masters and
mistresses in the night, they went before them carrying a lanthorne
and candle in their hands, and a great long club on their neckes."—
Annales, p. 1040, edit. 1631. The frequency of this exclamation in
nocturnal quarrels might in process of time adapt the expression to
general occasion.
Scene 4. Page 199.
It is submitted that the stage exhibition of Elizabeth's christening
should be conducted according to the curious and circumstantial
details of the manner in which it was really performed, to be found
in Halle's Chronicle, and copied from him by Stowe into his Annales.
TROILUS AND CRESSIDA.
PROLOGUE.
... Priam's six-gated city.
In this, as well as in Dr. Farmer's subsequent note, it might have
been better to have quoted Caxton's translation of the Recuyles or
destruction of Troy, instead of Lydgate. In the edition of 1607 of the
former work, which, in all probability, is that used by the author of
the play, the gates of Troy are thus named; Dardan, Timbria, Helias,
Chetas, Troyen, Antenorides. These are nearer to the text than those
in the other quotation from Lydgate, whose work the author does
not seem to have consulted. Should the curious reader be desirous
of seeing the manner in which Troy was formerly represented, he
may be gratified by an inspection of it in its full glory; the gates
inscribed with their names, and fortified with portcullises, in the
edition of Jaques Milot's Mystere de la destruction de Troye, Lyon,
1544, folio; or in Raoul le Fevre's Recueil des hystoires Troyennes,
Lyon, 1510, folio. This was also a favourite subject in old tapestry, a
very fine and ancient specimen of which remained a long time in the
painted chamber that separates the two houses of parliament, till it
was removed during the repairs of Saint Stephen's chapel for the
accommodation of the Irish members. A copy of it was fortunately
taken by that ingenious artist, Mr. John Carter, draughtsman to the
Society of Antiquaries.
ACT I.
Scene 1. Page 223.
Tro. Thou lay'st in every gash that love hath given me
The knife that made it.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookluna.com