Programming in C

Lecture 4: CONTROL FLOW

CHRIS STAFF
Dept. of Computer Science and Artificial Intelligence
University of Malta

Next Lecture: Functions and Program Structure


Lecture Outline

Aims and Objectives
More about if
switch
Conditional Expressions
More Loops
break and continue


Aims and Objectives


More about if

if-else

	if (expression)
		statement1
	else
		statement2
	
	/* where the else is optional */
else-if

	if (expression)
		statement
	else if (expression)
		statement
	else if (expression)
		statement
	else if (expression)
		statement
	else
		statement


switch


Conditional Expressions

The atoi function is in the stdlib library.


More Loops

do-while


break and continue


Exercises


Next Lecture...

Functions and Program Structure