CPF Lab04 if-switch and flowchart
CPF Lab04 if-switch and flowchart
1. Get input from the user as char (a,b,c… g). print “a for Apple” in case the user inputs
character ‘a’ and print “b for a boy’ in case of user inputs character ‘b’ and so on.
(Should be from a to z but the minimum is from a to k)
2. Get input of name and gender then print back to screen based on gender. If the
gender is male or m print “hello Mr. ……” otherwise print “hello miss …..”.
3. Get input as year then check if the input year is the leap year or not.
4. Get input as character then check whether a given character is a vowel or consonant
using switch statement.
5. Get input as number then print the day of the week based on the given number (1 for
Sunday, 2 for Monday, etc.) using switch statement.
6. Get input as a number and print the corresponding month based on the given number
(1 for January, 2 for February, etc.) using a switch statement.
7. Prompts the user to input 3 decimal numbers, assigning them to variables 'a', 'b', and
'c' respectively. Calculate their sum and average and then print the results.
8. Ask the user to input the width and height of a rectangle. Calculate the area of the
rectangle and provide a detailed explanation of the operation.
9. Get input as year then check if the input year is the leap year or not.
10. Get input as character then check whether a given character is a vowel or consonant
using switch statement.
11. Ask the user to input two values to store in 2 variables a and b, perform the swapping,
and then print the new values of the variables. Example: if a=5 and b=10, after swap
operation the value of a=10 and b=5.
12. Tet input as a number and print the corresponding month based on the given number
(1 for January, 2 for February, etc.) using a switch statement.
GOOD LUCK !