You are on page 1of 18

C Programming

MTRX 1702 – Software Component


Who am I?
• Dr Teresa Vidal-Calleja
• Australian Centre for Field Robotics (ACFR)
• Room: 302 Link Building
• Availability: Limited outside of lectures.
• Phone: 90367234
• Email: t.vidal@acfr.usyd.edu.au
Lectures and Labs
• Lectures:
– Wednesday 12-13 (Civil Eng LR3)

• Labs: 2 hours per week


– Wednesday 9-11
– Thursday 14-16
– Tuesday 11-13

• Any problems?
– Call x672354 outside Link building
– Email: t.vidal@acfr.usyd.edu.au
– Contact a tutor – Rose St building
Tutors

• Lachlan McCalman
l.mccalman@acfr.usyd.edu.au

• John Vial
j.vial@acfr.usyd.edu.au

• Mark De Deuge
m.dedeuge@acfr.usyd.edu.au
Textbooks
Prescribed Textbook:
• Bailey, T. An Introductory Course on C Programming and Software Design
This text is the lecture notes for this course. It is available online at

www-personal.acfr.usyd.edu.au/tbailey/ctext/
Recommended Textbooks:
• Kernighan, B.W. & Ritchie, D.M. The C Programming Language. 2nd Ed.
The textbook you will probably turn to as you gain experience. Written by the creator of C
(Ritchie), it is authoritative and complete.
• Deitel, H.M. and Deitel, P.J., C: How to Program. 3rd Ed.
An alternative introductory textbook. Very simple. Many code examples.
• Oualline, S. Practical C Programming
An alternative introductory textbook. Simpler than K&R. Quite good.
Course Information
• Course material accessible from AMME website.

www.aeromech.usyd.edu.au/MTRX1702/Course_Material/

• Look at the software engineering component for:


– Lecture slides
– Lab material
– Assignments
– On-line resources
– News
Class Diversity
• I expect a wide range of diversity regarding familiarity with
programming concepts and C.
– Some will be quite proficient.
– Some will be complete novices.
• We have a lot to cover in this course and will move quickly.
– Everything you need to know will be explained in lectures and labs, but
you will need to work hard to keep up.
• Please ask questions if there is anything you don’t understand.
– If you don’t ask, I won’t know that you don’t know.
• Remember that many aspects of programming will become
clearer by looking at example code and doing the labs.
Feedback
• Please provide feedback
– Problems with course material or presentation
– Problems with labs
– Constructive criticism (or praise)
• Do so by sending me an email
• If you want something fixed or desire some
modification of the course, let me know sooner rather
than later
How to Do Well
• Attend lectures and labs.
• Read the lecture notes. Read ahead and come to class prepared.
• Read the lab sheet in advance.
– Work through lab questions in the allotted time.
– Ask questions if you don’t understand.
– Keep up to date.
• Experiment with writing and debugging code during labs.
– This is an essential part of gaining an understanding of the C language
and its use.
• Submit assignments that are neatly presented and on time.
Assessment
• Two Assignments (50%)
• Two-hour Exam (50%)

• Each week lab-work is given.


– Attending and participating in labs is compulsory.
– Understanding code and writing programs is the only way to learn to program.
– This is not a course that you can cram in stu-vac.

• Experiment with code-modules during labs. Use the debugger.


• Work through the labs and lectures, and the exam will be simple!
Why Learn C?
After all, C is over 30 years old. There are other newer languages now.

1. C will be the language used in several later courses.


2. The exists C compilers on virtually all platforms, so your code can be
readily ported and run anywhere.
3. C is high-level, yet “close to the machine”. So, it is commonly used in
embedded programming.
4. C remains the language of choice in many other areas also. For example,
systems programming, graphics, numerics, real-time control, etc. Thus, it
means real jobs.
5. There exists a huge base of existing C code that must be maintained.
Again, real jobs.
6. There exists a huge number of open-source libraries for C (e.g., see
SourceForge.com). This code is often of excellent quality and can be used
directly in your project.
Course Objectives
• Introduce the C programming language as a practical
programming tool.
• Introduce the basic concepts of software design.
– Learn to design, code, and debug complete C programs.
– Learn how to decompose large problems into manageable
systems of modules. Design for correctness, flexibility,
extensibility, maintainability.
Brief History of ANSI/ISO C
• C pioneered by Dennis Ritchie at AT&T Bell Labs, early ‘70s
• Most early C compilers based on an appendix in the 1st Edition
of Kernighan & Ritchie – so called K&R C.
• K&R C has some unspecified details: it is has aspects that are
ambiguous and incomplete.
• Many incompatible dialects of C were appearing, hindering
portability.
• ANSI committee X3J11 formed in 1983 to standardise C; they
reported in 1989.
• International ISO standard in 1990.
• See paper by Ritchie (1993) for more information on the history
and philosophy of C.
• The ISO standard was revised in 1999 giving us C99.
C Language Overview
• General purpose language: used for writing software in many
different domains (compilers, graphics, games, embedded
systems, etc)
• A “small” language - 32 keywords
• With a small level of experience, can expect to know, and
regularly use, the entire language.
• Provides modern “high-level” control constructs: decisions,
loops, functions.
• Provides “low-level” capabilities: manipulate characters (bytes)
and addresses.
How can the Language be so Small?
• It relies on library functions:
– no operations that deal directly with composite objects (e.g. strings, lists, arrays,
matrices, collections)
– no memory management facilities (apart from static definition and stack
allocation).
– no input or output facilities (eg, print to the screen, write to a file, etc)
• These operations require explicitly called functions.
– eg, many languages provide a keyword to print to the screen (eg, Fortran has a
PRINT instruction).
– The C language has no such keyword, and we use the standard library function
printf() to print.
• C comes with a standard library that provides a collection of commonly used
functions (145 of them).
• All C programs are composed of functions, and we will cover functions
extensively in this course.
Some Example Programs

• hello.c: a traditional first program


• hello2.c
• tempf.c
• tempf2.c

#include <stdio.h>
int main(void)
{
printf("Hello, world!\n");
return 0;
}
How does C work?
Homework
• Get a copy of the lecture notes off the web.
• Review chapters 1 and 2 of lecture notes. (Today's
lecture and next lecture)

• Lecture notes contain many small code snippets. These


might be more understandable as complete working
programs, which, for Chapters 1 – 3, can be found on
the textbook webpage.

You might also like