Q6. Write a logical if statement that will test for the following conditions: (a) If the cell value in Al is larger than the cell value in A2 then write in cell A3–“Al beats A2", otherwise write “A2 beats Al". Test this with values of: Al-20 and A2=10; (2) A1 =15 and A2=30; (3) Al =15 and A2=15. What happens with (3) and can you suggest how you can modify the if statement to deal with ties? (b) If the content of cell Al is between 0 and 50 write “Class A"; If the content of Al is betweer 51 and 100 write “Class B"; If neither then write "Class C". Place the function in cell A2 and test with 23, 56, and 94. (c) If the content of cell Al is between 34 and 76 or 145 and 453 write “In Range", otherwise write “Out of Range". Place the function in A2 and test with 12, 36, 87, 243, and 564. Hint: this will require you to use other logical functions (OR, AND, etc.). (d) If the contents of cell A1 > 23 and the contents of cell A2 < 56 then write "Houston we have a problem" in cell A3. Otherwise write “Onward through the fog" in cell
Control structures
Control structures are block of statements that analyze the value of variables and determine the flow of execution based on those values. When a program is running, the CPU executes the code line by line. After sometime, the program reaches the point where it has to make a decision on whether it has to go to another part of the code or repeat execution of certain part of the code. These results affect the flow of the program's code and these are called control structures.
Switch Statement
The switch statement is a key feature that is used by the programmers a lot in the world of programming and coding, as well as in information technology in general. The switch statement is a selection control mechanism that allows the variable value to change the order of the individual statements in the software execution via search.
Step by step
Solved in 2 steps