C Programming - Sheet 1
C Programming - Sheet 1
ــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ
ــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ
ــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ
ــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ
ــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ
?2- Which of the following is a valid variable name and which is not valid
7 / 22 22 / 7 7 % 22
22 % 7 3*4 3 * 4.0
𝑏
𝑥=𝑎+ 𝑐
𝑦= ( 𝑎+𝑏
2 )×0. 324
𝑧=1+ ( 3
𝑎+𝑏 )− 𝑑
6- Evaluate the following and determine the type of the returned value:
a. math.floor (15.8)
f. math.log2(8)
8- Write a program that asks a student for his grade (out of 100) in 3 exams and
then print out his final grade (out of 100), given that the weight of the first
exam is 30%, the second 30%, and the third 40%.
Program Constant:
Program inputs:
Program outputs:
Relevant Formulas:
𝑑𝑖𝑠𝑡𝑎𝑛𝑐𝑒
𝑡𝑖𝑚𝑒 = 𝑣𝑒𝑙𝑜𝑐𝑖𝑡𝑦 × cos𝑐𝑜𝑠 (𝑡ℎ𝑒𝑡𝑎)
2
𝑔 × 𝑡𝑖𝑚𝑒
ℎ𝑒𝑖𝑔ℎ𝑡 = 𝑣𝑒𝑙𝑜𝑐𝑖𝑡𝑦 × sin 𝑠𝑖𝑛 (𝑡ℎ𝑒𝑡𝑎) ×𝑡𝑖𝑚𝑒 − 2
Angle: 0.3
Velocity: 800
Distance: 11000
Example Output:
Time = 14.392834521148679
Height = 70.63171358313048