C Overview
This class will cover the basic syntax of C including
- Elements of a program
- Variables and arithmetic expressions
- Variable names
- Data types and sizes
- Constants
Because the program development process is so different from what you may be used to from CSC 151, we will also discuss how to compile and run C programs.
Overview
A program in the C programming language (or other computer languages) indicates a sequence of detailed instructions that specify the steps to be followed to solve a problem. In other words, programs provide a mechanism for communicating algorithms.
Because a program articulates a proposed algorithm to accomplish a desired task, the code should be considered as a formal mechanism for precise communication. As a communication vehicle, a program has at least three audiences:
- The author:
- When developing a program, the author must be able to review the steps for logical correctness, completeness, and efficiency. Programs might become long and complex. When a program is clear and easy to read, the author can review the program's logic and effectiveness.
- Other people:
- In a class setting, an instructor and perhaps other students may read an algorithm to review correctness and efficiency and to gain insights in alternative approaches for solving a problem. In a software development environment (e.g., in industry), original programs are changed by new groups of developers to expand capabilities and meet new needs.
- Computers:
- Algorithms written in C and other programming languages can be interpreted by computers, allowing the machines to follow the instructions. Computers execute algorithms and thereby help solve problems.
Throughout this course, we will write code that addresses the needs of all three audiences. Code with a specific syntax can be utilized by a computer, but code written just for a machine often misses the point.
When code lacks clarity, an author often will miss a detail that leads to errors. When code is not easy to read, an author may find it difficult and time consuming to locate errors. On the other hand, when code is clear and easy to read, finding problems often is reasonably straight forward.
As you begin to program in C, you will encounter many mechanics and details that may seem unintuitive and awkward Since the C environment may be new and different, it may take some time to become comfortable with the syntax and process.
Don't panic! Before long (perhaps a few days), many of these mechanics will become familiar, and you will be able to focus on more conceptual elements of problem solving with C.
Textbook Reading
- King: Chapter 2 and Section 3.1, pages 9-32 and 37-42
First program in C
Read this annotated
quarts.c program.