08.01.2023 Views

Learn to Program with C_ Learn to Program using the Popular C Programming Language ( PDFDrive )

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

■ Contents

■Chapter ■ 5: Programs with Repetition Logic 91

5.1 Introduction .............................................................................................................. 91

5.2 The while Construct ................................................................................................ 91

5.2.1 Highest Common Factor .............................................................................................................. 96

5.3 Keep a Count ............................................................................................................ 97

5.3.1 Find Average................................................................................................................................ 99

5.4 Increment and Decrement Operators ..................................................................... 100

5.5 Assignment Operators ............................................................................................ 101

5.6 Find Largest ........................................................................................................... 102

5.7 Find Smallest ......................................................................................................... 105

5.8 Read Data from a File ............................................................................................. 106

5.8.1 fscanf...................................................................................................................................... 108

5.8.2 Find Average of Numbers in a File ............................................................................................. 108

5.9 Send Output to a File .............................................................................................. 110

5.9.1 fprintf......................................................................................................................................... 111

5.10 Payroll .................................................................................................................. 112

5.11 The for Construct ................................................................................................ 118

5.11.1 The for Statement in C ........................................................................................................... 120

5.11.2 A Bit of Aesthetics .................................................................................................................... 125

5.12 Multiplication Tables ............................................................................................. 125

5.13 Temperature Conversion Table ............................................................................. 129

5.14 Expressive Power of for ...................................................................................... 131

5.15 The do...while Statement ................................................................................ 132

5.15.1 Highest Common Factor .......................................................................................................... 133

5.15.2 Interest at the Bank ................................................................................................................. 134

■Chapter ■ 6: Characters 141

6.1 Character Sets ........................................................................................................ 141

6.2 Character Constants and Values............................................................................. 142

6.3 The Type char ........................................................................................................ 143

x

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!