Introduction to Computing – B142L
Getting started with C programming
Academic year
2011/12
Objectives:
- Outline of unit syllabus and coursework
- Advantages of software programming
- Characteristics of the C programming language
- Parts of a C program
Websites for unit information and coursework
Unit information is online at:
Coursework is online at:
The original computing device
An abacus:
- Where is the hardware?
- Where is the software?
- Where is the data storage?
- Who were the programmers?
|  |
First general purpose electronic computer
Electronic Numerical Integrator and Computer (ENIAC) in 1946:
- Where is the hardware?
- Where is the software?
- Where is the data storage?
- Who were the programmers?
|  |
The most common model for computers
John von Neumann is credited with the design for a
stored-program computer. This concept that has been applied to mainstream computer hardware since 1945.
Hardware and software
Computing is the automation of tasks that benefit from repetition.
- History shows that there are risks from automation, too.
- Computing innovation initially focused on hardware development.
Software are solutions for problems that can be implemented using computers.
- Software often implement an algorithm or procedure.
- Software are compiled into instructions for specific types of computing hardware.
|  |
Why do we need software for these products?
Why use a programming language?
A processor instruction is an electronic circuit.
Common categories of processor instructions:
- Data movement
- Arithmetic and logical
- Comparison
- Conditional jumps and branching
- Input and output
A programming language is a set of symbols (characters) and syntax rules that can be used to describe detailed instructions for a microprocessor or a virtual machine.
We use programming languages because they allow:
- Non-specialists to use specialist hardware
- Creation of better software with less effort
The C programming language
The C programming language was developed in 1972 at AT&T Bell Labs (
related article).
Steps to create a C program
Review questions
Development of computers
From 1946 until the late 1980s, innovations in computing were mostly in which area?
Review questions
Development of computers
Which area of computing has
not increased due to innovations?
Review questions
Software development life cycle
A
compiler converts source code into what type of object?
Review questions
Software development life cycle
In which situation would you be
required to re-compile a program?
C is a procedural language
Standard error (
stderr) is often directed to the same destination as standard output.
Writing C programs

The
main() function is
required for all C programs.
- The main() function is the where the program starts.
- The program ends when the main() function ends.
- The main() function should be defined before all other functions.
Writing C programs

This
preprocessor directive is used to
include the source code from the
stdio.h header file into the current program.
- Header files have names ending with a .h extension.
- Header files used with a program should be included at the top of the source code file for easier maintenance.
Writing C programs

C programs use 2 types of
statements:
- Simple statements end with a semicolon.
- Compound statements are enclosed in braces. Compound statements contain one or more simple statements.
Writing C programs
Function calls require a
pair of parentheses after the name of the function.
- Optionally, input parameters are provided by including it within the parentheses.
- A comma is required to separate multiple input parameters.
Writing C programs
Comments start with
/* and continue until it reaches a matching
*/ end.
Do
not use C++, Java or PHP style comments, which use a double forward slash at the indicate the start of comments.
// Do not use comments in this style. They reduce portability between C compilers.
Reserved keywords in the C language
Reserved keywords are often highlighted with a different color in the editor and may
not be used as names of functions or data.
| auto | const | double | float | int | short | struct | unsigned |
| break | continue | else | for | long | signed | switch | void |
| case | default | enum | goto | register | sizeof | typedef | volatile |
| char | do | extern | if | return | static | union | while |
Software development life cycle
It is important to use the
version control and
comments in your Mosaic coursework page to record your progress.
Review questions
C language syntax
Why is C considered a
procedural programming language?
Review questions
C language syntax
Comments must be written at the top of a program before the
main() function.
Review questions
C language syntax
Which item in the list below is
not considered to be part of the C language
syntax.