0% found this document useful (0 votes)
2 views

C Programming - Sheet 1

This document outlines a programming course (CS111) at the Arab Academy for Science and Technology, focusing on C programming tasks. It includes exercises on printing messages, variable naming, evaluating expressions, and writing programs for calculating costs and projectile motion. The document serves as a guide for students to practice and apply their programming skills in various scenarios.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

C Programming - Sheet 1

This document outlines a programming course (CS111) at the Arab Academy for Science and Technology, focusing on C programming tasks. It includes exercises on printing messages, variable naming, evaluating expressions, and writing programs for calculating costs and projectile motion. The document serves as a guide for students to practice and apply their programming skills in various scenarios.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

‫‪Arab Academy for Science and Technology and Maritime Transport‬‬

‫‪College of Computing and Information Technology‬‬


‫‪Course‬‬ ‫)‪Introduction to Computing (CS111‬‬
‫‪Lecturer(s) Dr. Ehab Ahmed, Dr. Shaimaa ElMorsy, Dr. Yasmine Nagy‬‬
‫‪Abdelrahman Samy, Ghada Aslan, Mahmoud ElMorshedy, Norhan Dwair,‬‬
‫)‪TA(s‬‬
‫‪Sara Mohamed, Ziad ElKhazindar‬‬

‫ــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ‬
‫ــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ‬
‫ــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ‬
‫ــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ‬
‫ــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ‬

‫‪Programming in C – Sheet 1‬‬

‫”!‪1- Write a C program to print the following message: “Hello World‬‬

‫?‪2- Which of the following is a valid variable name and which is not valid‬‬

‫‪Break‬‬ ‫‪Max_Num‬‬ ‫‪while‬‬


‫‪G‬‬ ‫‪Sue’s‬‬ ‫‪#insert‬‬
‫‪Part20%‬‬ ‫‪print‬‬ ‫‪int‬‬
‫‪variable54‬‬ ‫‪five_percent‬‬ ‫‪_stuff‬‬
‫‪g2b-55xyz‬‬ ‫‪gig..balance‬‬
3- Indicate the type of the following C values:
14 15.0 True ‘$’
-999 0.123 ‘R’ “R”
‘True’ 32e-4 ‘-5’ 0.0

4- Evaluate the following expressions:

7 / 22 22 / 7 7 % 22
22 % 7 3*4 3 * 4.0

5- Write the following expressions as valid C expressions:

𝑏
𝑥=𝑎+ 𝑐

𝑦= ( 𝑎+𝑏
2 )×0. 324
𝑧=1+ ( 3
𝑎+𝑏 )− 𝑑
6- Evaluate the following and determine the type of the returned value:

a. math.floor (15.8)

b. math.floor (15.8 + 0.5)

c. math.ceil (-7.2) * math.pow (4.0, 2.0)

d. math.sqrt (math.floor (math.fabs (-16.8)))


e. math.log10 (1000.0)

f. math.log2(8)

7- A Manufacturer wishes to determine the cost of producing an open-top


cylindrical container. The surface area of the container is the sum of the area of
the circular base plus the area of the outside (the circumference of the base
times the length of the container). Write a program to take the radius of the
base, the height of the container, and the cost per square cm of the material.
Calculate and display the cost of each cylindrical container.

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%.

9- Write a computer program that computes the duration of a projectile’s flight


and its height when it reaches the target.

Program Constant:

g = 32.17 # Gravitational constant #

Program inputs:

theta (float) # angle of elevation (in radians) #


distance (float) # distance to target (in ft) #
velocity (float) # projectile velocity (in ft/sec) #

Program outputs:

time (float) # time of flight #


height (float) # height at impact #

Relevant Formulas:

𝑑𝑖𝑠𝑡𝑎𝑛𝑐𝑒
𝑡𝑖𝑚𝑒 = 𝑣𝑒𝑙𝑜𝑐𝑖𝑡𝑦 × cos𝑐𝑜𝑠 (𝑡ℎ𝑒𝑡𝑎)

2
𝑔 × 𝑡𝑖𝑚𝑒
ℎ𝑒𝑖𝑔ℎ𝑡 = 𝑣𝑒𝑙𝑜𝑐𝑖𝑡𝑦 × sin 𝑠𝑖𝑛 (𝑡ℎ𝑒𝑡𝑎) ×𝑡𝑖𝑚𝑒 − 2

Example Input (prompt user as follows):

Angle: 0.3
Velocity: 800
Distance: 11000

Example Output:

Time = 14.392834521148679
Height = 70.63171358313048

You might also like