Skip to main content

Part of the book series: Undergraduate Texts in Computer Science ((UTCS))

  • 2467 Accesses

Abstract

Like other high-level programming languages, C has the ability to make decisions by comparing values. Two values can be tested for equality, for example, and one block of statements can be executed if the values are equal. Another block of statements, or no statements at all, can be executed if the values aren’t equal. The purpose of such decision-making statements should already be clear from the discussion of pseudocode commands in Chapter 1. Also, we have already used some implementations of the pseudocode IF…THEN…ELSE statement in Chapters 2 and 3 in code for reading files. For instance, in the statements

status=fscanf(infile,…); if (status == EOF) break;

and

infile=fopen(name,“r”);

if (infile == NULL)

printf(“Can’t find file.”); else …

if … statements are used to respond appropriately when the end-of-file mark is found or when the program can’t find a requested file.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 54.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 69.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info
Hardcover Book
USD 109.99
Price excludes VAT (USA)
  • Durable hardcover edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 1999 Springer Science+Business Media New York

About this chapter

Cite this chapter

Brooks, D.R. (1999). Selection and Repetition Constructs. In: C Programming: The Essentials for Engineers and Scientists. Undergraduate Texts in Computer Science. Springer, New York, NY. https://doi.org/10.1007/978-1-4612-1484-7_4

Download citation

  • DOI: https://doi.org/10.1007/978-1-4612-1484-7_4

  • Publisher Name: Springer, New York, NY

  • Print ISBN: 978-1-4612-7161-1

  • Online ISBN: 978-1-4612-1484-7

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics