2: Selection

When solving tasks for this topic, you cannot use: strings, arrays, loops, functions min and max.

2.1 Smallest Number

Coding Exercise: Smallest Number
Input three numbers. Write a program to output the smallest number.
Use only one nested if and do NOT use and,or, to solve this problem.
You may enter input for the program in the box below.

2.2 Middle number

Coding Exercise: Middle number
Input three numbers. Output the middle number.
Use logical operators and, or, not to minimize the amount of if-else statements.
You may enter input for the program in the box below.

2.3 Not 0 digits

Coding Exercise: Not 0 digits
Given a four digit number. Output the number of its digits that are not equal to 0. You are allowed to use a loop if know how to.
You may enter input for the program in the box below.

2.4 Leap Year

Coding Exercise: Leap Year
The leap year has 366 days, the common year has 365 days. The year is leap if it is divisible by 4 and not divisible by 100, or the year is divisible by 400.
Given the year. Write a program to calculate the number of days in the given year.
You may enter input for the program in the box below.

2.5 Product of digits

Coding Exercise: Product of digits
Given an integer 3 digit number. Write a program to find out if the number is divisible by the product of its digits. If the number is divisible, output the quotient, otherwise output 0.
For example, if the given number is equal to 312, the output should be 52, because 312 divided by 6 (i.e. 3*1*2) is equal to 52.
You may enter input for the program in the box below.

2.6 1 sec. before

Coding Exercise: 1 sec. before
Given three numbers that correspond the time, i.e. hours and minutes and seconds. Write a program to find the time before 1 second. When solving this task use 24 hour clock.
You may enter input for the program in the box below.

2.7 Duration of Activity

Coding Exercise: Duration of Activity
Given four integer numbers. The first two numbers correspond the activity starting time (hours and minutes), the other two numbers correspond the activity finishing time (hours and minutes). Calculate how much time the activity lasted. Output two numbers, i.e. the duration of the activity expressed in hours and minutes.
When solving this task use 24 hour clock. Assume that the activity lasted less than 24 hours
For example, if the given numbers are 15 20 16 48, they mean that the activity started at 15:20 and finished at 15:48. Your output should be 1 28, because the activity lasted for 1 hour and 28 minutes.
You may enter input for the program in the box below.