October 1996OUCS
Programming in Cl9.2/2
Contents
1 Introduction1
1.1 About this Userguide11.2 Why use C?1
2 An Example C Program23 Variables and Expressions3
3.1 Variable Declaration33.2 Variable Types33.3 Variable Names43.4 Assignment53.5 Arithmetic Operators63.6 Increment and Decrement Operators73.7 Cast Operators73.8 Bitwise Operators ‡73.9 Promotions and Conversions ‡83.10 Parsing Rules ‡103.11 Symbolic Constants and The Preprocessor11
4 Input and Output11
4.1 Formatted Output —
printf
114.2 Conversion Specifiers124.3 Literal Constants134.4 Formatted Input —
scanf
154.5 Character I/O —
getchar
&
putchar
164.6 End-of-File17
5 Flow of Control17
5.1 Relational and Logical Operators175.2 Conditional Branching —
if
185.3 Conditional Selection —
switch
195.4 Iteration —
while
,
for
205.5 Local Jumps —
goto
‡215.6 Short Circuit Behaviour ‡225.7 Problems225.8 Declaring Array Variables235.9 Initialising Array Variables24
6 Functions25
6.1 Building Blocks of Programs256.2 Return Value256.3 Function Parameters25