ebook img

C Programming: An Introduction PDF

364 Pages·2017·1.887 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview C Programming: An Introduction

C P rogramming LICENSE, DISCLAIMER OF LIABILITY, AND LIMITED WARRANTY C By purchasing or using this book (the “Work”), you agree that this license grants permission to use the contents contained herein, but does not give you P rogramming the right of ownership to any of the textual content in the book or ownership to any of the information or products contained in it. This license does not permit uploading of the Work onto the Internet or on a network (of any kind) A Self-Teaching Introduction without the written consent of the Publisher. Duplication or dissemination of any text, code, simulations, images, etc. contained herein is limited to and subject to licensing terms for the respective products, and permission must be obtained from the Publisher or the owner of the content, etc., in order to reproduce or network any portion of the textual material (in any media) that is contained in the Work. Mercury Learning and inforMation (“MLI” or “the Publisher”) and anyone involved in the creation, writing, production, accompanying algorithms, code, or computer programs (“the software”), and any accompanying Web site or software of the Work, cannot and do not warrant the performance or results that might be obtained by using the contents of the Work. The author, developers, and the Publisher have used their best efforts to insure the accuracy and functionality of the textual material and/or programs contained in this package; we, however, make no warranty of any kind, express or implied, regarding the performance of these contents or programs. The Work is sold “as is” without warranty (except for defective materials used in manufacturing the book or due to faulty workmanship). The author, developers, and the publisher of any accompanying content, and anyone involved in the composition, production, and manufacturing of this work will not be liable for damages of any kind arising out of the use of (or the inability to use) the algorithms, source code, computer programs, or textual material contained in this publication. This includes, but is not limited to, loss of revenue or profit, or other incidental, physical, or consequential damages arising out of the use of this Work. The sole remedy in the event of a claim of any kind is expressly limited to replacement of the book and only at the discretion of the Publisher. The use M L i of “implied warranty” and certain “exclusions” vary from state to state, and erCury earning and nforMation Dulles, Virginia might not apply to the purchaser of this product. Boston, Massachusetts New Delhi C P rogramming A Self-Teaching Introduction By RAJIV CHOPRA, PhD M L i erCury earning and nforMation Dulles, Virginia Boston, Massachusetts New Delhi Copyright ©2018 by Mercury Learning and inforMation. All rights reserved . Reprinted and revised with permission. Original title and copyright: Introduction to Programming (C) Copyright © 2017 by New Age International (P) Ltd. Publishers. All rights reserved. ISBN : 978-93-86070-20-3 This publication, portions of it, or any accompanying software may not be reproduced in any way, stored in a retrieval system of any type, or transmitted by any means, media, electronic display or mechanical display, including, but not limited to, photocopy, record- ing, Internet postings, or scanning, without prior permission in writing from the publisher. Publisher: David Pallai Mercury Learning and inforMation 22841 Quicksilver Drive Dulles, VA 20166 [email protected] www.merclearning.com 1-800-232-0223 R. Chopra. C Programming: A Self-Teaching Introduction. ISBN: 978-1-68392-090-8 The publisher recognizes and respects all marks used by companies, manufacturers, and developers as a means to distinguish their products. All brand names and product names mentioned in this book are trademarks or service marks of their respective companies. Any omission or misuse (of any kind) of service marks or trademarks, etc. is not an attempt to infringe on the property of others. Library of Congress Control Number: 2017934665 171819321 Printed in the USA on acid-free paper. Our titles are available for adoption, license, or bulk purchase by institutions, corporations, etc. For additional information, please contact the Customer Service Dept. at 800-232- 0223(toll free). All of our titles are available in digital format at authorcloudware.com and other digital vendors. The sole obligation of Mercury Learning and inforMation to the purchaser is to replace the book, based on defective materials or faulty workmanship, but not based on the operation or functionality of the product. C ontents Preface viii Acknowledgments x Chapter 1: C Overview 1 1.0 Introduction 1 1.1 The Concept of Algorithms and Pseudocodes 2 1.2 Flowcharts 8 1.3 Compiler Overview 15 1.4 Assembler, Linker, and Loader 19 1.5 Structure of a Simple “Hello World” Program in C 22 1.6 O verview of the Compilation and Execution Process in an Integrated Development Environment (preferably CodeBlock) 30 Summary 32 Exercises 32 Chapter 2: Programming Using C 35 2.0 Introduction 35 2.1 Preprocessor Directives/Compiler Directives/C Preprocessor 35 2.2 C Primitive Input-Output using getchar and putchar 40 2.3 Simple Input/Output 42 2.4 Function Calls from a Library 44 2.5 Data Types in C 44 2.6 Enumeration 47 2.7 Operators 51 2.8 Type Casting (or Coercion) in C 62 vi • Contents 2.9 Conditional Executing Using If-Else 63 2.10 Switch and Break 68 2.11 T he Concept of Loops—While Loop, Do-While Loop, For Loop, Nested Loops, Break Statement, Continue Statement 73 2.12 Storage Classes: Auto, Static, Extern, and Register 119 Summary 135 Exercises 135 Chapter 3: Arrays And Pointers 141 3.0 Introduction 141 3.1 1D, 2D, and 3D Arrays 142 3.2 The Concept of Subprogramming 212 3.3 Functions 213 3.4 P arameter Transmission Techniques—Call by Value and Call by Reference 228 3.5 Pointers 234 3.6 Relationship between Array and Pointer 239 3.7 Argument Passing Using Pointers 241 3.8 Array of Pointers 243 3.9 Passing Arrays as Arguments 244 Summary 269 Exercises 269 Chapter 4: Structures And Unions 275 4.0 Introduction 275 4.1 Structures versus Unions 296 4.2 Structures and Pointers 298 Summary 312 Exercise Questions 313 Chapter 5: File Handling In C 317 5.0 Introduction 317 5.1 File Pointers 317 5.2 Character Input / Output with Files 320 5.3 String I/O Functions 321 5.4 Integer I/O Functions 321 5.5 Formatted I/O Functions 322 5.6 Block (or Record) I/O Functions 323 Summary 338 Exercises 338 Contents • vii Appendices 341 A: C Programming Lab Projects 341 B: Keywords in C 343 C: Escape Sequences in C 344 D: Operator Precedence and Associativity 345 E: Standard Library String Functions 346 References 347 Index 349 P refaCe The right temperament required for research originates from the right expo- sure and environment that a student receives during study. And good books help in this direction. Programming is an art. You have to learn this art, as only then will you learn how to write good programs. This book is an outcome of lecture notes prepared during my long years of teaching Introduction to Programming (C), augmented by consulting a large number of books available on the subject. I thank my students, colleagues, and teachers, as well as all the authors who have helped in shaping my approach to this knowledge.

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.