Learn to Program with C: Learn to Program using the Popular C Programming Language

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

This book teaches computer programming to the complete beginner using the native C language. As such, it assumes you have no knowledge whatsoever about programming. The main goal of this book is to teach fundamental programming principles using C, one of the most widely used programming languages in the world today.

We discuss only those features and statements in C that are necessary to achieve our goal. Once you learn the principles well, they can be applied to any language. If you are worried that you are not good at high-school mathematics, don't be. It is a myth that you must be good at mathematics to learn programming.
C is considered a 'modern' language even though its roots date back to the 1970s. Originally, C was designed for writing 'systems' programs--things like operating systems, editors, compilers, assemblers and input/output utility programs. But, today, C is used for writing all kinds of applications programs as well--word processing programs, spreadsheet programs, database management programs, accounting programs, games, robots, embedded systems/electronics (i.e., Arduino), educational software--the list is endless.
Note: Appendices A-D are available as part of the free source code download at the Apress website.
What You Will Learn:




How to get started with programming using the C language


How to use the basics of C
How to program with sequence, selection and repetition logic


How to work with characters


How to work with functions


How to use arrays
Who This Book Is For: This book is intended for anyone who is learning programming for the first time.

Author(s): Noel Kalicharan
Publisher: Apress
Year: 2015

Language: English
Pages: 312

Contents at a Glance
Contents
About the Author
About the Technical Reviewer
Acknowledgements
Preface
Chapter 1: Elementary Programming Concepts
1.1 Programs, Languages, and Compilers
1.2 How a Computer Solves a Problem
1.2.1 Define the Problem
1.2.2 Analyze the Problem
1.2.3 Develop an Algorithm to Solve the Problem
1.2.3.1 Data and Variables
1.2.3.2 Example—Develop the Algorithm
1.2.4 Write the Program for the Algorithm
1.2.5 Test and Debug the Program
1.2.6 Document the Program
1.2.7 Maintain the Program
1.3 How a Computer Executes a Program
1.4 Data Types
1.5 Characters
1.6 Welcome to C Programming
1.6.1 Run the Program
1.6.2 A Word on Program Layout
1.7 Write Output with printf
1.7.1 The Newline Character, \n (backslash n)
1.7.2 Escape Sequences
1.7.3 Print the Value of a Variable
1.8 Comments
1.9 Programming with Variables
Chapter 2: C – The Basics
2.1 Introduction
2.2 The C Alphabet
2.3 C Tokens
2.3.1 Spacing Within a Program
2.3.2 Reserved Words
2.3.3 Identifiers
2.3.4 Some Naming Conventions
2.4 Basic Data Types
2.5 Integer Numbers - int
2.5.1 Declaring Variables
2.5.2 Integer Expressions
2.5.3 Precedence of Operators
2.5.4 Print an Integer Using a “Field Width”
2.6 Floating-Point Numbers – float and double
2.6.1 Print double and float Variables
2.6.2 Assignment Between double and float
2.6.3 Floating-Point Expressions
2.6.4 Expressions with Integer and Floating-Point Values
2.6.5 Assigning double/float to int
2.7 Strings
2.8 The Assignment Statement
2.9 printf
Chapter 3: Programs with Sequence Logic
3.1 Introduction
3.2 Read Data Supplied by a User
3.3 scanf
3.3.1 Read Data Into a float Variable
3.3.2 Read Data Into a double Variable
3.4 Read Strings
3.5 Examples
3.5.1 Problem 1 - Average
3.5.2 Problem 2 - Square
3.5.3 Problem 3 - Banking
3.5.4 Problem 4 – Tickets
Chapter 4: Programs with Selection Logic
4.1 Introduction
4.2 Boolean Expressions
4.2.1 AND, &&
4.2.2 OR, ||
4.2.3 NOT, !
4.2.3.1 The data type bool in C99
4.3 The if Construct
Program P4.1
4.3.1 Find the Sum of Two Lengths
Program P4.2
Program P4.3
4.4 The if...else Construct
Program P4.4
4.4.1 Calculate Pay
Program P4. 5
4.5 On Program Testing
4.6 Symbolic Constants
Program P4. 6
4.6.1 The #define Directive
4.6.2 Example – Symbolic Constants
Program P4.7
4.7 More Examples
4.7.1 Print a Letter Grade
Program P4.8
4.7.2 Classify a Triangle
Program P4.9
Chapter 5: Programs with Repetition Logic
5.1 Introduction
5.2 The while Construct
5.2.1 Highest Common Factor
5.3 Keep a Count
5.3.1 Find Average
5.4 Increment and Decrement Operators
5.5 Assignment Operators
5.6 Find Largest
5.7 Find Smallest
5.8 Read Data from a File
5.8.1 fscanf
5.8.2 Find Average of Numbers in a File
5.9 Send Output to a File
5.9.1 fprintf
5.10 Payroll
5.11 The for Construct
5.11.1 The for Statement in C
5.11.2 A Bit of Aesthetics
5.12 Multiplication Tables
5.13 Temperature Conversion Table
5.14 Expressive Power of for
5.15 The do...while Statement
5.15.1 Highest Common Factor
5.15.2 Interest at the Bank
Chapter 6: Characters
6.1 Character Sets
6.2 Character Constants and Values
6.3 The Type char
6.4 Characters in Arithmetic Expressions
6.4.1 Uppercase To/From Lowercase
6.5 Read and Print Characters
6.6 Count Characters
6.6.1 Count Characters in a Line
6.7 Count Blanks in a Line of Data
6.8 Compare Characters
6.9 Read Characters from a File
6.10 Write Characters to a File
6.10.1 Echo Input, Number Lines
6.11 Convert Digit Characters to Integer
Chapter 7: Functions
7.1 About Functions
7.2 skipLines
7.3 A Program with a Function
7.3.1 The Function Header
7.3.2 How a Function Gets Its Data
7.4 max
7.5 Print the Day
7.6 Highest Common Factor
7.6.1 Using HCF to Find LCM
7.7 factorial
7.7.1 Using Factorial
7.7.2 Combinations
7.8 Job Charge
7.9 Calculate Pay
7.10 Sum of Exact Divisors
7.10.1 Classify Numbers
7.11 Some Character Functions
7.11.1 Position of a Letter in the Alphabet
7.12 Fetch the Next Integer
Chapter 8: Arrays
8.1 Simple vs Array Variable
8.2 Array Declaration
8.3 Store Values in an Array
8.3.1 About Not Using Element 0
8.4 Average and Differences from Average
8.5 Letter Frequency Count
8.6 Making Better Use of fopen
8.7 Array as Argument to a Function
8.8 String – Array of Characters
8.8.1 Reverse the Characters in a String
8.9 Palindrome
8.9.1 A Better Palindrome Function
8.10 Array of Strings – Name of Day Revisited
8.11 A Flexible getString Function
8.12 A Geography Quiz Program
8.13 Find the Largest Number
8.14 Find the Smallest Number
8.15 A Voting Problem
Chapter 9: Searching, Sorting, and Merging
9.1 Sequential Search
9.2 Selection Sort
9.2.1 Analysis of Selection Sort
9.3 Insertion Sort
9.3.1 Analysis of Insertion Sort
9.3.2 Insert an Element in Place
9.4 Sort an Array of Strings
9.4.1 Variable-Length Arrays
9.5 Sort Parallel Arrays
9.6 Binary Search
9.7 Word Frequency Count
9.8 Merge Sorted Lists
They can be combined into one ordered list, C, as follows:
9.8.1 Implement the Merge
Chapter 10: Structures
10.1 The Need for Structures
10.2 How to Declare a Structure
10.2.1 typedef
10.3 Array of Structure
10.4 Search an Array of Structure
10.5 Sort an Array of Structure
10.6 Read, Search, and Sort a Structure
10.7 Nested Structures
10.8 Work with Fractions
10.8.1 Manipulate Fractions
10.9 A Voting Problem
10.10 Pass Structures to Functions
Index