CHAPTER 3

image

Programs with Sequence Logic

In this chapter, we will explain the following:

  • The idea of reading data supplied by a user
  • How the scanf statement works
  • How to read numeric data using scanf
  • How to read string data using gets
  • Important principles of program writing using several examples

3.1 Introduction

In the last chapter, we introduced some of C’s basic data types—int, double, and float—and used simple statements to illustrate their use. We now go a step further and introduce several programming concepts by writing programs using these types.

The programs in this chapter will be based on sequence logic—that simply means the statements ...

Get Learn to Program with C now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.