1.5 Conditional Statements academy.zariba.com 1
Lecture Content 1.If-else statements 2.If-else-if statements 3.Switch-case statements 2
Comparison Operators 3 OperatorNotation Equals== Not Equals!= Greater Than> Greater Than or Equals>= Less Than< Less Than or Equals<=
Logical Operators 4 OperatorNotation Not! And&& Or|| XOr^
1. If-else and if-else-if Statments 5
2. Switch Case statements 6
Homework 7 1.Write an if statement that exchanges the values of 2 numbers if the first is bigger than the second 2.Write a program that finds the largest of 3 integers, using if statements. 3.Sort 3 integer numbers using if statements. 4.Write a program that enters a number from 10 to 19 and prints on the console the name of the number. E.g. 11 – “eleven”. Use switch. 5.Write a boolean expression for finding if the bit 2 (counting from 0) of a given integer is 1 or 0. 6.Write an expression that checks if a given point (x,y) is within a circle with radius 4 and centre at (0,0) 7.*We are given 5 integer numbers. Write a program that checks if there is a subset of these 5 numbers which sums to zero. List all such sums. E.g. 5,0,-2,-3,1 should print 1.) 0 =0 2.) 5-2-3=0.
8 References
9 Zariba Academy Questions