Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Lab Exercises

Lab 2
1. Get the age of two different people and compare if their ages are the same or not, if it
is the same, display “They are at the same age”. If not, display “Ages are different”.

2. Draw the flowchart that gets a year from user and display how many years passed
since 1900. If the given input is less than 1900 display “you are ancient!”.

3. Get a whole number from user, if it is an odd number, display it. If it is an even
number divide the number to 2 and display the result. Hint: if (x mod 2) equals to 0
then the number is even.

4. Create a computer algorithm that calculates and displays the sum of all even whole
numbers between 5 and 105.

5. Create a computer algorithm that displays all odd whole numbers between 10 and 100

6. Create a computer algorithm to find squares and cubes of a specific number starting
from 1 up to that number. The algorithm will ask the user to enter the whole number.
The algorithm will then show the square and cube of all the numbers up to that
number (including the number itself).
EXAMPLE:
INPUT NUMBER: 3
Number Square Cube
1 1 1
2 4 8
3 9 27

7. Create a computer algorithm that displays a conversion table for degrees Fahrenheit to
degrees Celsius beginning with 20oF through 100oF in steps of 5oF. The conversion
formula is given below: Celsius = 5(Fahrenheit – 32) / 9
EXAMPLE:
20F -6C
25F -5C
8. Create a computer algorithm that would calculate the result of the following formula:
90

∏𝑋
𝑥=10
9. Create a computer algorithm that would get the number n from the user and calculate
the result of the following formula below:
1000

∑ 𝑋𝑛
𝑥=!

You might also like