Sunteți pe pagina 1din 2

Cairo University Faculty of Engineering Credit Hour System GENN004

Lab 02 Arithmetic Operations


________________________________________________________________________ All scripts should be stored in your FirstLastName folder and have clear names 1. Write a program to calculates this expression:

Given that X=5, Y=2, Z=4. 2. Write a program to calculate the area and the perimeter of a circle given that its radius equal 5cm. Area = pi * R * R Perimeter = 2 * pi *R 3. The density of the Helium gas used in air balloons changes by time and its the controller of the altitude and velocity of the balloon. Thus the air balloons velocity and altitude mainly depends on the time spent hanging in the air. The relation between the velocity and altitude of the balloon and the time spent hanging in the air could be approximated by the following polynomial equations:
v(t ) 0.48t 3 36t 2 760t 4100 alt(t ) 0.12t 4 12t 3 380t 2 4100t 220

Where v is the velocity (m/hour), alt is the altitude (m), and t is the time (hours). Write a program to calculate the expected velocity and altitude given the time. Example Input Time (hours) Output Altitude = Velocity =

35

12.645 1.020

KMs KMs/hour

4. Write a program to interchange the value of two variables. Hint: use a third variable to do that. 5. A cylindrical-shape glass of height 5 inches and base radius 2 inches. If water is poured into the glass at 2 gallons per hour, write a program to calculate how long it takes to fill in the glass. One gallon is 7.5 cubic feet and one foot is 12 inches. 6. Write a program to split an array of length 10 into two arrays; one containing the elements of odd indices and the other containing the elements of even indices. For example: A=[8 9 7 8 2 3 4 5 8 7] will be split into A1=[8 7 2 4 8] and A2 = [9 8 3 5 7].

Lab 02

1/2

Cairo University Faculty of Engineering Credit Hour System GENN004

7. Given length, width and height of a cuboid, we need to calculate its surface area, volume, and largest distance between any two points. The largest distance between any two points is calculated as follows:
Lar _ Dis length2 width2 hieght 2

Example Input Length (m) Width (m) Height (m)

= = =

13.00 21.40 17.23

Output Largest Distance Total Surface Area Volume

= = =

30.394 1741.820 4793.386

m m2 m3

8. Given temperature values in Celsius units, calculate the corresponding values of Fahrenheit, Rankin, and Kelvin units according to these relations: TF TR 459 .67
9 TF TC 32 5 9 TR TK 5

Example Input Celsius: 27.00 C Output 27.00 C = = =

80.60 540.27 300.15

Fahrenheit Rankin Kelvin

9. Write program that calculate the remainder of division of two integer (dont use rem function). Example: remainder of dividing 14 by 4 equal 2.

Lab 02

2/2

S-ar putea să vă placă și