0% found this document useful (0 votes)
74 views

Introprogramming-Tutorial Sheets-Week 4 Tut 2

The document discusses topics for a computer programming tutorial, including nested conditional statements and switch statements. It provides [1] examples of programs to get a color from the user and display if it is in the rainbow using switch and if-else statements, and [2] a program to find the maximum of three numbers using if-else. It also [3] asks students to determine the output of a nested if statement code and modify it so the else is associated with either the inner or outer if statement.

Uploaded by

i_khandelwal
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
74 views

Introprogramming-Tutorial Sheets-Week 4 Tut 2

The document discusses topics for a computer programming tutorial, including nested conditional statements and switch statements. It provides [1] examples of programs to get a color from the user and display if it is in the rainbow using switch and if-else statements, and [2] a program to find the maximum of three numbers using if-else. It also [3] asks students to determine the output of a nested if statement code and modify it so the else is associated with either the inner or outer if statement.

Uploaded by

i_khandelwal
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Birla Institute of Technology & Science, Pilani Second Semester 2013-2014, Computer Programming [CS F111] Week #4Tutorial

Sheet 2 [35 min] Topics to be discussed: Nested Conditional Construct Switch Statement [5 mins] Review of recorded content on nested ifs and switch statements. Explain switch clearly. [15 min] Write a program that takes a character indicating a color from the user and (using switch statement) displays whether that color is present in the rainbow. If its present, then display the full color as well. Rewrite the program using the if-else if construct. Emphasis is on switch statement, break with switch, and converting switch to if else.

[10mins] Write a program to find the maximum of three numbers using if-else construct. [5 min] Find the output of the following codes, assuming the integer variables contain initially the values x = 25, i = 10, j = 8, z = 18, k = 3 if(x == 25) if( i> j) if( k > 5) z = k; else z = 20; printf( The value of z is %d , z); With which statement does elsegets associated with inner if or the outer if? Modify the above code in such a way that the code is no more misleading, so that the else gets associated with a) inner most if statement b) outer most if statement

You might also like