In this module, we study conditional statements like if and
else that you use in C to have parts of your code run only if
certain conditions are true, and loops such as while and for
while provide the facilities through which you get parts of your
code to repeat a number of times, or until a certain condition
is met.
This topic is presented on public courses
Programming in C,
C and C++ Programming
Examples from our training material
| cb.c | Using { and } to scope a block |
| makefile | makefile for module C203 |
| sindol.c | Singapore Teapot answer |
| sindy.c | Singapore teapot in C |
| tall.c | Temperature conversions using if |
| tall2.c | Temperature conversions using switch |
| tall3.c | Temperature conversions in a while loop |
| tall4.c | Temperature conversions with ++ and += |
| tall6.c | Temperature conversions in a while loop |
Opentalk forum discussions related to this topic
double comparisons within an if statDouble type rounding
Background information
Some modules are
available for download as a sample of our material or under an
Open Training Notes License for free download from
http://www.training-notes.co.uk.
Topics covered in this module
The if statement.
Writing conditions in C.
Exercise.
if, else, elseif.
switch, case, default.
while.
++ and += operator families.
Exercise.
do while.
for.
break and continue.
goto and labels.
Layout of your blocks, and comments revisited.
Exercise.
Complete learning
If you are looking for a complete course and not just a information on a single subject, visit our
Listing and schedule page.
Well House Consultants specialise in training courses in
Python,
Perl,
PHP, and
MySQL. We run
Private Courses throughout the UK (and beyond for longer courses), and
Public Courses at our training centre in Melksham, Wiltshire, England.
It's surprisingly cost effective to come on our public courses -
even if
you live in a different
country or continent to us.
We have a technical library of over 600 books on the subjects on which we teach.
These books are available for reference at our training centre. Also
available is the Opentalk
Forum for discussion of technical questions.