Page 1 of 37Free preview · 1–5

About this document

An introductory C programming book for readers with no prior programming experience. Its 32-chapter curriculum covers writing programs, variables, strings, operators, decision-making, loops, arrays, pointers, memory management, structures, files, and functions. Appendixes provide an ASCII table and a Draw Poker program. The supplied excerpt includes front matter, the complete table of contents, the introduction, Chapter 2 with sample programs, and the index.

Free preview text

The first 5 pages, shown as text so search engines and readers can find this document.

Page 2

C Programming Greg Perry and Dean Miller 800 East 96th Street Indianapolis, Indiana 46240 Third Edition

Page 3

C Programming Absolute Beginner’s Guide Third Edition Copyright © 2014 by Pearson Education, Inc. All rights reserved. No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without written permission from the publisher. No patent liability is assumed with respect to the use of the information contained herein. Although every precaution has been taken in the preparation of this book, the publisher and authors assume no responsibility for errors or omissions. Nor is any liability assumed for damages resulting from the use of the information contained herein. ISBN-13: 978-0-7897-5198-0 ISBN-10: 0-7897-5198-4 Library of Congress Control Number: 2013943628 Printed in the United States of America Trademarks All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized. Que Publishing cannot attest to the accuracy of this information. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark. Warning and Disclaimer Every effort has been made to make this book as complete and as accurate as possible, but no warranty or fitness is implied. The information provided is on an “as is” basis. The authors and the publisher shall have neither liability nor responsibility to any person or entity with respect to any loss or damages arising from the information contained in this book or from the use of the programs accompanying it. Bulk Sales Que Publishing offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales. For more information, please contact U.S. Corporate and Government Sales 1-800-382-3419 corpsales@pearsontechgroup.com For sales outside the United States, please contact International Sales international@pearsoned.com Acquisitions Editor Mark Taber Managing Editor Sandra Schroeder Project Editor Mandie Frank Copy Editor Krista Hansing Editorial Services, Inc. Indexer Brad Herriman Proofreader Anne Goebel Technical Editor Greg Perry Publishing Coordinator Vanessa Evans Interior Designer Anne Jones Cover Designer Matt Coleman Compositor TnT Design, Inc. Third Printing: January 2015

Page 4

Contents at a Glance Introduction........................................................................................................... 1 Part I: Jumping Right In 1 What Is C Programming, and Why Should I Care? ................................ 5 2 Writing Your First C Program.................................................................. 13 3 What Does This Do? Clarifying Your Code with Comments............... 23 4 Your World Premiere—Putting Your Program’s Results Up on the Screen ..................................................................................... 31 5 Adding Variables to Your Programs....................................................... 41 6 Adding Words to Your Programs ........................................................... 49 7 Making Your Programs More Powerful with #include and #define ........................................................................ 57 8 Interacting with Users .............................................................................. 65 Part II: Putting C to Work for You with Operators and Expressions 9 Crunching the Numbers—Letting C Handle Math for You ................. 73 10 Powering Up Your Variables with Assignments and Expressions ....... 83 11 The Fork in the Road—Testing Data to Pick a Path............................. 91 12 Juggling Several Choices with Logical Operators .............................103 13 A Bigger Bag of Tricks—Some More Operators for Your Programs ........................................................................................115 Part III: Fleshing Out Your Programs 14 Code Repeat—Using Loops to Save Time and Effort .......................123 15 Looking for Another Way to Create Loops .........................................131 16 Breaking in and out of Looped Code ..................................................141 17 Making the case for the switch Statement .....................................149 18 Increasing Your Program’s Output (and Input) ...................................163 19 Getting More from Your Strings ...........................................................171 20 Advanced Math (for the Computer, Not You!) ...................................181 Part IV: Managing Data with Your C Programs 21 Dealing with Arrays ................................................................................193 22 Searching Arrays.....................................................................................201 23 Alphabetizing and Arranging Your Data .............................................209 24 Solving the Mystery of Pointers ............................................................221 25 Arrays and Pointers ................................................................................231 26 Maximizing Your Computer’s Memory ................................................243 27 Setting Up Your Data with Structures ..................................................257

Page 5

iv Part V: Files and Functions 28 Saving Sequential Files to Your Computer .........................................267 29 Saving Random Files to Your Computer .............................................277 30 Organizing Your Programs with Functions ..........................................285 31 Passing Variables to Your Functions ....................................................293 32 Returning Data from Your Functions ...................................................305 Appendixes A The ASCII Table .....................................................................................313 B The Draw Poker Program ......................................................................319 Index ..................................................................................................................331

Page 6

Table of Contents Introduction ...................................................................................................................... 1 Who’s This Book For?................................................................................................ 2 What Makes This Book Different? ........................................................................... 2 This Book’s Design Elements ................................................................................... 3 How Can I Have Fun with C? ................................................................................... 4 What Do I Do Now? .................................................................................................. 4 Part I: Jumping Right In 1 What Is C Programming, and Why Should I Care? ............................................ 5 What Is a Program? ................................................................................................... 6 What You Need to Write C Programs ..................................................................... 7 The Programming Process...................................................................................... 10 Using C ..................................................................................................................... 11 2 Writing Your First C Program ..............................................................................13 A Down-and-Dirty Chunk of Code ........................................................................ 14 The main() Function ............................................................................................. 16 Kinds of Data ........................................................................................................... 17 Characters and C ................................................................................................ 18 Numbers in C ...................................................................................................... 19 Wrapping Things Up with Another Example Program ........................................ 21 3 What Does This Do? Clarifying Your Code with Comments..........................23 Commenting on Your Code ................................................................................... 24 Specifying Comments ............................................................................................. 25 Whitespace............................................................................................................... 27 A Second Style for Your Comments ...................................................................... 28 4 Your World Premiere—Putting Your Program’s Results Up on the Screen.................................................................................................31 How to Use printf() ........................................................................................... 32 The Format of printf() ................................................................................. 32 Printing Strings......................................................................................................... 33

Tags

Doxxly editorial guide

C Programming Absolute Beginner’s Guide, Third Edition: summary, contents and background

This guide helps you understand the scope of C Programming Absolute Beginner’s Guide, Third Edition before or alongside reading the original document. It is based on the catalogue record, credited creator, source, classification and topics shown on this page. It does not replace the original work and does not invent claims about passages that Doxxly cannot verify.

Summary and overview

C Programming Absolute Beginner’s Guide, Third Edition is a 37-page documentcredited to Kaya J. Vance. An introductory C programming book for readers with no prior programming experience. Its 32-chapter curriculum covers writing programs, variables, strings, operators, decision-making, loops, arrays, pointers, memory management, structures, files, and functions. Appendixes provide an ASCII table and a Draw Poker program. The supplied excerpt includes front matter, the complete table of contents, the introduction, Chapter 2 with sample programs, and the index. It appears in the Education & Learning collection, which groups it with other material that readers may use for comparison and further study.

The item can be approached in several ways. A reader looking for a quick orientation can begin with the free five-page preview, inspect the page structure and use the metadata to judge relevance. Someone undertaking deeper research can work through the complete file, search its indexed text, record useful page references and compare its treatment of C programming, Beginner programming, Programming textbook, Variables and data types, Control flow, Arrays and strings, Pointers, Memory management, Structures, File handling, Functions with the related resources linked below.

Rather than reducing the work to a single claim, this page treats it as a source that should be read in context. The title, creator, publication source, licence and format all help explain what kind of evidence it may offer. Readers should distinguish the original author's statements from Doxxly's catalogue description, and should cite the original edition when using the material in academic, professional or published work.

Key topics and reader takeaways

The catalogue connects this document with C programming, Beginner programming, Programming textbook, Variables and data types, Control flow, Arrays and strings, Pointers, Memory management, Structures, File handling, Functions. These terms offer practical entry points rather than a substitute for close reading. Start by identifying the definitions, examples, arguments, tables or visual explanations attached to each topic. Then note where the creator draws connections, makes distinctions or moves from background material to a conclusion, recommendation, calculation or narrative development.

A useful reading method is to separate description from interpretation. First record what the item actually presents: names, headings, figures, formulas, quotations or stated propositions. Next consider why those details matter within the whole work. Finally compare them with another source from the same subject area. This process helps turn a long digital file into evidence that can be evaluated rather than merely skimmed.

Table of contents and reading guide

The following is an editorial content guide based on the verified catalogue topics. It is not represented as the original author's formal table of contents. Use it to organise notes while moving through the 37 pages in the player.

  1. Part 1

    C programming

    Use this section of the reading guide to identify how C programming appears in C Programming Absolute Beginner’s Guide, Third Edition, note important terms, and connect the subject to the wider purpose of the work.

  2. Part 2

    Beginner programming

    Use this section of the reading guide to identify how Beginner programming appears in C Programming Absolute Beginner’s Guide, Third Edition, note important terms, and connect the subject to the wider purpose of the work.

  3. Part 3

    Programming textbook

    Use this section of the reading guide to identify how Programming textbook appears in C Programming Absolute Beginner’s Guide, Third Edition, note important terms, and connect the subject to the wider purpose of the work.

  4. Part 4

    Variables and data types

    Use this section of the reading guide to identify how Variables and data types appears in C Programming Absolute Beginner’s Guide, Third Edition, note important terms, and connect the subject to the wider purpose of the work.

  5. Part 5

    Control flow

    Use this section of the reading guide to identify how Control flow appears in C Programming Absolute Beginner’s Guide, Third Edition, note important terms, and connect the subject to the wider purpose of the work.

  6. Part 6

    Arrays and strings

    Use this section of the reading guide to identify how Arrays and strings appears in C Programming Absolute Beginner’s Guide, Third Edition, note important terms, and connect the subject to the wider purpose of the work.

  7. Part 7

    Pointers

    Use this section of the reading guide to identify how Pointers appears in C Programming Absolute Beginner’s Guide, Third Edition, note important terms, and connect the subject to the wider purpose of the work.

  8. Part 8

    Memory management

    Use this section of the reading guide to identify how Memory management appears in C Programming Absolute Beginner’s Guide, Third Edition, note important terms, and connect the subject to the wider purpose of the work.

When a heading in the original differs from this guide, follow the original heading in your citation. Page numbers can also vary between editions. Doxxly's direct page field is useful for navigation, but formal references should include the title, creator, source and edition details available in the file itself.

About Kaya J. Vance

Doxxly credits Kaya J. Vance as the author or creator of C Programming Absolute Beginner’s Guide, Third Edition. This page does not add an unverified biography, job title or institutional affiliation. The attribution is preserved so readers can distinguish the creator from the hosting library and follow the original record when an external author link is available.

Author context matters because a work reflects a particular purpose, audience and point of view. Before relying on the material, consider what the creator set out to explain, when the source was produced and whether later research or revised guidance should also be consulted. For literature and philosophy, compare translations and editions; for technical material, check whether a newer version has superseded the one shown here.

About the source organisation

The recorded source for this item is ptgmedia.pearsoncmg.com. Doxxly provides access and discovery tools but does not claim to be the original publisher unless explicitly stated. Source links, creator attribution and the recorded Publicly available file collected for editorial review licence are displayed to help readers assess provenance and permitted use.

Provenance is especially important for reports, standards, presentations and working spreadsheets. Check the original source for amendments, supporting files and current policy. A trustworthy research workflow keeps the source URL with any notes or downloaded copy, verifies important figures against the original, and avoids treating an archived document as automatically current.

Visit ptgmedia.pearsoncmg.com

How to read and use this document

Begin with the title and opening pages, then use the guide above to decide whether to read sequentially or move to a particular topic. The Doxxly player provides previous and next navigation, a direct page field, zoom steps, fit-to-width and fit-to-page modes, rotation and fullscreen. These controls are useful when a page contains small type, a wide table, an image, a scanned layout or a dense sequence of notes.

The first five pages are open to every visitor. A plan unlocks the complete item and full-document search. Search is best used for distinctive names, technical terms or short phrases; broad words can produce too many possible contexts. When you find a useful passage, read the surrounding pages so that a sentence, chart or formula is not separated from its explanation.

If downloading is enabled, members can obtain the original PDF file. Keep the original format when formulas, slide sequencing, pagination or layout carries meaning. Respect the Publicly available file collected for editorial review terms displayed on this page, and use the rights-report link if you believe the attribution or availability needs review.

Research questions to consider

As you read C Programming Absolute Beginner’s Guide, Third Edition, ask which audience the creator addresses, what problem or idea organises the work, what evidence is presented, and which assumptions remain unstated. Note whether important terms are defined consistently and whether examples represent a broader pattern or a narrow case. For quantitative material, record units, time periods, formulas and data sources. For interpretive material, separate the creator's language from your own summary.

A second set of questions concerns relevance today. Which parts remain durable, which depend on their historical or institutional setting, and what would need confirmation from a newer source? Following the tags and the Education & Learning collection can reveal useful comparisons. Agreement between sources can strengthen confidence, while disagreement can point to changing definitions, methods, evidence or priorities.

Finally, decide what you need from the item: background knowledge, a quotation, a worked example, a model, a visual explanation or a starting bibliography. That purpose should guide the depth of reading and the notes you keep. Doxxly helps locate and navigate the source; careful interpretation remains the reader's responsibility.

Explore more Education & Learning resources

Frequently asked questions about C Programming Absolute Beginner’s Guide, Third Edition

Practical answers about reading, downloading and understanding this document on Doxxly.

More in Education & Learning