Presentation is loading. Please wait.

Presentation is loading. Please wait.

Silberschatz and Galvin  1999 1.1 C Programming Language Decision making in C Kingdom of Saudi Arabia Ministry of Higher Education Al-Majma’ah University.

Similar presentations


Presentation on theme: "Silberschatz and Galvin  1999 1.1 C Programming Language Decision making in C Kingdom of Saudi Arabia Ministry of Higher Education Al-Majma’ah University."— Presentation transcript:

1 Silberschatz and Galvin  1999 1.1 C Programming Language Decision making in C Kingdom of Saudi Arabia Ministry of Higher Education Al-Majma’ah University College of Education - Zulfi Computer Department المملكة العربية السعودية وزارة التعليم العالي جامعة المجمعة كلية التربية بالزلفي قسم الحاسب الآلي Teacher: Chafika LAABIDI OUNI WANNASSI c.ouni@mu.edu.sa

2 Silberschatz and Galvin  1999 1.2 Definition Decision making structures require that the programmer specify one or more conditions to be evaluated or tested by the program, along with a statement or statements to be executed if the condition is determined to be true, and optionally, other statements to be executed if the condition is determined to be false.

3 Silberschatz and Galvin  1999 1.3 General form

4 Silberschatz and Galvin  1999 1.4 if statement An if statement consists of a boolean expression followed by one or more statements. Syntax:

5 Silberschatz and Galvin  1999 1.5 if statement An if statement consists of a boolean expression followed by one or more statements. Syntax:

6 Silberschatz and Galvin  1999 1.6 if statement

7 Silberschatz and Galvin  1999 1.7 if statement Example:

8 Silberschatz and Galvin  1999 1.8 if...else statement An if statement can be followed by an optional else statement, which executes when the boolean expression is false. Syntax:

9 Silberschatz and Galvin  1999 1.9 if...else statement

10 Silberschatz and Galvin  1999 1.10 if...else statement Example:

11 Silberschatz and Galvin  1999 1.11 The if...else if...else Statement An if statement can be followed by an optional else if...else statement, which is very useful to test various conditions using single if...else if statement.

12 Silberschatz and Galvin  1999 1.12 The if...else if...else Statement Syntax:

13 Silberschatz and Galvin  1999 1.13 The if...else if...else Statement Example:

14 Silberschatz and Galvin  1999 1.14 The if...else if...else Statement Example:

15 Silberschatz and Galvin  1999 1.15 Nested if statement It is always legal in C programming to nest if- else statements, which means you can use one if or else if statement inside another if or else if statement(s). Syntax:

16 Silberschatz and Galvin  1999 1.16 Nested if statement Example:

17 Silberschatz and Galvin  1999 1.17 Switch statement A switch statement allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being switched on is checked for each switch case. Syntax:

18 Silberschatz and Galvin  1999 1.18 Switch statement

19 Silberschatz and Galvin  1999 1.19 Switch statement Example:

20 Silberschatz and Galvin  1999 1.20


Download ppt "Silberschatz and Galvin  1999 1.1 C Programming Language Decision making in C Kingdom of Saudi Arabia Ministry of Higher Education Al-Majma’ah University."

Similar presentations


Ads by Google