BN.com Gift Guide

C by Example

( 1 )

Overview

C By Example makes programming easy to learn for the beginning programmer. It builds your programming skills by using clear, easy-to-understand exercises. Hands-on, real world examples show you how to write programs that flow correctly and produce accurate results. At the end of the book, you will use the concepts you have learned to build a blackjack game. Also included is an appendix that discusses where to find compilers, other C resources, where to go from here, and what kinds of careers you could go into ...

See more details below
Paperback (REVISED & UPDATED)
$29.10
BN.com price
(Save 16%)$34.99 List Price
Other sellers (Paperback)
  • All (9) from $2.00   
  • New (3) from $22.51   
  • Used (6) from $2.00   
Sending request ...

Overview

C By Example makes programming easy to learn for the beginning programmer. It builds your programming skills by using clear, easy-to-understand exercises. Hands-on, real world examples show you how to write programs that flow correctly and produce accurate results. At the end of the book, you will use the concepts you have learned to build a blackjack game. Also included is an appendix that discusses where to find compilers, other C resources, where to go from here, and what kinds of careers you could go into with the knowledge she gained from the book.

Read More Show Less

Product Details

  • ISBN-13: 9780789722393
  • Publisher: Que
  • Publication date: 12/13/1999
  • Series: By Example Series
  • Edition description: REVISED & UPDATED
  • Edition number: 2
  • Pages: 528
  • Product dimensions: 7.32 (w) x 8.97 (h) x 1.18 (d)

Meet the Author

Greg Perry is a bestselling author and co-designer of the by Example series. He has written more than 50 computer books, many of which are bestsellers. He has been a programmer, trainer, and speaker for the past 20 years. Previously, Greg taught advanced programming courses at Tulsa Community College. He currently lectures at programming conferences across the country and is fluent in 9 computer languages. Among his bestselling books are Sams Teach Yourself Beginning Programming in 24 Hours, C by Example, Sams Teach Yourself Visual Basic 6 in 21 Days, and Sams Teach Yourself Windows 98 in 24 Hours.

Read More Show Less

Read an Excerpt

Chapter 1: What C is all About

C Is Fundamental

Just a few years ago, C was the most popular programming language being used. Programmers wrote C code for PCs, mainframes, and supercomputers. C was standardized so that the same program would run on every kind of computer using every kind of operating system available.

Today, the use of C has dramatically decreased. Rarely will a project be written in C. Programmers are using languages such as C++ and Java to create applications that run on standalone, networked, and Internet-based machines. Yet, when learning to program, C is considered to be the one language it is imperative a programmer master before moving on to the other languages in use today.

TIP

Due to the Internet's phenomenal growth, new languages are appearing to handle the different challenges that Internet-based processing requires. Companies looking for programmers in these newer, and sometimes obscure, languages often advertise for C programming skills. The companies know that someone well-versed in C can pick up these offshoot languages rapidly. Therefore, learning C will boost your career potential even if you are never hired to write C-based code.

The reason for C's recommended mastery, despite its low levels of actual use, is that C is the common denominator of many of today's languages; learn C and these languages will be simple to learn. Languages such as C++ and Java are based on C. In fact, many of the statements and commands in these newer languages are identical to the ones found in C. Overall, C is much simpler to learn than these languages because it carries with it a much slimmer toolkit of add-on procedures.

CAUTION

When some people attempt to learn C, even if they are programmers in other lan- guages, they find that C can be cryptic and difficult to understand. This does not have to be the case. When you are taught to write clear and concise C code, in an order that builds on fundamental programming concepts, C is no more difficult to learn or use than any other programming language.

The History of C

Before you jump into C, you might find it helpful to know a little about the evolution of the C programming language. Bell Labs first developed this language in the early 1970s, primarily so that Bell programmers could write their UNIX operating system for a new DEC (Digital Equipment Corporation) computer. Bell Labs designed UNIX to run efficiently on small equipment, and it was the first operating system to be written entirely in a high-level programming language. Until that time, operating systems were written in assembly language, the computer's low-level, hardware-based language that is tedious, time-consuming, and difficult to change. The Bell Labs designers knew they needed a higher-level programming language to implement their project quicker and make its code easier to maintain.

Because other high-level languages at the time (COBOL, FORTRAN, PL/I, and Algol) were too slow to use for an operating system's code, the Bell Labs programmers decided to write their own language. They based their new language on Algol and BCPL, two high-level but efficient languages used throughout the European markets, but rarely in America. BCPL strongly influenced C, although BCPL did not offer the various data types that the makers of C required. After a few versions, these Bell programmers developed a language that met their goals very well. C is efficient (it is sometimes called a high low-level language due to its speed of execution) and flexible, and contains the proper constructs enabling it to be maintained over time.

How C Differs

If you have programmed before, you should understand a little about how C differs from other programming languages on the market. (Today's new Cbased languages, such as Java, also contain many of C's nuances.) Besides being a very efficient language, C is known also as a weakly typed language; that is, the data types you assign to variables do not necessarily require that same type of data. (Proper coding techniques learned in this book, however, will help to eliminate this problem.) If you declare a numeric variable, and then decide to put a letter into it, C enables you to do this. The data may not be in the format you expect, but C does its best. This is much different than stronger-typed languages such as COBOL and Pascal. These languages require rigid conformity to consistent data types; you cannot store, for example, a character in a numeric storage location. Although you can get into trouble a little more easily, C enables you to view the same data in different ways.

C's weakly typed nature places much more responsibility on the programmer. C is an extremely flexible language-particularly if it is to be used to write operating systems. At any one time, an operating system does not know what is coming down the line. If, for example, an operating system expects a number but instead receives a letter, the language used must be flexible enough to handle this different data without aborting.

programmer has more freedom with data storage, the languages do not check data type accuracy for the programmer. The trade-off is worth it, however. The designers of C did not want to hamper C programmers by adding lots of strict rules to the language.

C is a small, block-structured programming language. C has fewer than 40 keywords. To make up for its small vocabulary, C has one of the largest assortments of operators, such as those used for calculations and data comparisons. (The C-based languages have more operators than virtually every other language in existence, second only to AIPL.) The large number of operators in C could tempt programmers to write cryptic programs that do a lot with a small amount of code. As you learn throughout this book, however, making the program more readable is more important than squeezing out bytes. This book teaches you how to use the C operators to their fullest extent, while maintaining readable programs.

C's large number of operators (more than the number of keywords) requires a more judicious use of an operator precedence table that states the order in which C processes multiple operators inside a single statement.

V Appendix B, "C's Precedence Table," page 476, contains Cs operator precedence table that you can refer to as you learn C.

Unlike most other languages that have only four or five levels of precedence, C has 15. As you learn C, you need to master each of these 15 levels. The precedence table is not as difficult as it sounds, but its importance cannot be overstated.

C also has no input or output statements. (You might want to read that sentence again!) C has no commands that perform input or output. This is one of the most important reasons why C and C-based languages are available on so many different computers. The I/O (input and output) statements of most languages tie those languages to specific hardware. QBasic, for instance, has almost 20 1/0 commands-some of which write to the screen, to the printer, to a modem, and so on. If you write a QBasic program for a microcomputer, chances are sky-high that the program cannot run on a mainframe.

C's input and output is performed through the abundant use of function calls. With every C compiler comes a library of standard 1/0 functions that your program calls to perform input and output. These standard routines are hardware independent, because they work on any device and on any computer that conforms to the ANSI C standard (as most do)...

Read More Show Less

Table of Contents

Introduction.

I. WELCOME TO C.

1. What C Is All About.

2. Analyzing C Programs.

3. Variables and Constants.

4. Introduction to Arrays.

5. Preprocessor Directives.

6. Input and Output.

II. C OPERATORS.

7. Operators and Precedence.

8. Relational and Logical Operators.

9. Remaining C Operators.

III. CONTROLLING YOUR PROGRAM'S EXECUTION.

10. The while Loop.

11. The for Loop.

12. Controlling Flow.

IV. VARIABLE SCOPE AND STRUCTURING CODE.

13. Introduction to C Functions.

14. Variable Scope and Structuring Code.

15. Passing Values Between Functions.

16. Returning Function Values.

V. STANDARD INPUT, OUTPUT, AND INTRINSIC FUNCTIONS.

17. Device and Character 1/0.

18. String and Numeric Functions.

VI. BUILDING BLOCKS.

19. Working with Arrays.

20. Pointer Storage.

21. Using Pointers.

VII. ADVANCED C.

22. Introduction to Structures.

23. Arrays of Structures.

24. Simple C File Processing.

25. Putting It All Together.

Read More Show Less

Customer Reviews

Average Rating 1
( 1 )
Rating Distribution

5 Star

(0)

4 Star

(0)

3 Star

(0)

2 Star

(0)

1 Star

(1)

Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation

Reminder:

  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

 
Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously
Sort by: Showing 1 Customer Reviews
  • Anonymous

    Posted September 1, 2000

    No stars is more appropriate

    This book is full of errors, and it made me wonder how come this author got so many misconceptions about C. You will, definitely, not learn C from this book. If you want to become a serious programmer in C, consult the 2000 book reviews at ACCU (Association for C and C++ Users) Internet site. If you just want to impress your friend at your first date, make sure your date does not know C better than this author, because this book is just as bad as so many C/C++ books available in the market.

    Was this review helpful? Yes  No   Report this review
Sort by: Showing 1 Customer Reviews

If you find inappropriate content, please report it to Barnes & Noble
Why is this product inappropriate?
Comments (optional)