CSCI101 Lab01 FirstProgram
CSCI101 Lab01 FirstProgram
4. Calculate and print the distance between two points (x1,y1) and (x2,y2)
𝐷𝑖𝑠𝑡 = √(𝑥2 − 𝑥1 )2 + (𝑦2 − 𝑦1 )2
6. Calculate and print the number of days in N hours and the remaining hours.
7. Calculate and print the number of trays, N, needed to hold X glasses if each tray
contains Y glasses.
8. If you distribute N apples in groups of 7 apples each, how many groups will contain
exactly 7 apples and how many apples remain?
10. Given temperature values in Celsius units (Tc), calculate the corresponding values
of Kelvin units (Tk) according to the following relations.
TF = TR − 459.67
9
TF = TC + 32
5
9
TR = TK
5
Page 1
University of Science and Technology
Communications & Information Engineering Program
CSCI 101: Introduction to Computer Science
First Program
11. Write a program that reads two values, X and Y, from the user. The program then
swaps the values of X and Y. You should print the values of X and Y before and
after swap.
Example:
Enter x:10
Enter y:20
Before swap: x=10, y =20
After swap: x=20, y =10
12. Write a program that asks the user for three one-digit numbers and then uses them
as units, tens, and hundreds to evaluate one 3-digit number out of them
Example:
Please enter units: 5
Please enter tens: 2
Please enter hundreds: 9
The number is: 925
Page 2