5 charts on South Africa as a source country for international student recrui...
C programming session 02
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
Notes de l'éditeur
Begin the session by explaining the objectives of the session.
Tell the students that they cannot create a useful programs without using the operators. A simple program such as adding two variables and showing the result needs the use of variables.
Operator precedence is very important in a program. If the operator precedence is not considered then the program might produce an unexpected result. Give an example, which produces a result different from the expected result because of incorrect operator precedence.
Use Slide 4 to test the student’s understanding on logical operators.
Use Slide 7 to test the student’s understanding on unary operators.
Use Slide 10 to test the student’s understanding on binary operators.
Use this slide to test the student’s understanding on binary operators.
Use this slide to test the student’s understanding on ternary operators.
Use this slide to test the student’s understanding on increment/decrement operators.
Explain definite and indefinite loops. Give some examples, which distinguish between definite and indefinite loops.
The for loop consists of three parts : Initialization Condition Re-initialization (increment/decrement) In a for loop, after initialization, the condition is first checked. If the condition is valid, the body of the for loop is executed. For each iteration, re-initialization is done before the condition is checked again. Any or all of these parts may be left out of the construct. For example : for ( ; ; ) { } is an infinite loop (as there is no condition).
Use this slide to test the student’s understanding on loops.
Use this slide to test the student’s understanding on controlling the loop execution.
When used with strings, the format string could be quite confusing. The statement: printf ( “%15.5s”, string) prints the first 5 characters of the string right-justified in 15 spaces. When used with floats, it represents the precision required.
Use this slide to test the student’s understanding on formatted output.
Use this slide to test the student’s understanding on formatted input.
Use this slide to test the student’s understanding on formatted input-output.
The output buffer is flushed only if it is full, or if the string to be printed contains a newline character at the end or if it is explicitly flushed using fflush () . The last option is used if the string does not contain a new line character. The string might not be displayed at the right place at the right time otherwise.
Use this and the next 4 slides to summarize this session.