dti2143 lab sheet 4

3
UNIVERSITI TUN HUSSEIN ONN MALAYSIA FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING DTI 2143: COMPUTER PROGRAMMING LAB EXERCISE 4 – SELECTION AND MATH.H Exercise 1: Write a program which asks from user for two round numbers and determine which one is larger. The output should similar to: Exercise 2: Write a program which asks the user to enter an exam mark, and then displays whether or not the mark is valid. Hence it will display the grade for that mark. 80-100 A 60-79 B 40-59 C 20-39 D 0-19 E Example of the program output display (user input is in bold): Enter your mark: 150 The exam mark must be between 0 and 100 inclusive.

Upload: alish-al-shahab

Post on 13-Feb-2017

421 views

Category:

Documents


0 download

TRANSCRIPT

UNIVERSITI TUN HUSSEIN ONN MALAYSIAFACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING DTI 2143: COMPUTER PROGRAMMING

LAB EXERCISE 4 – SELECTION AND MATH.H

Exercise 1:

Write a program which asks from user for two round numbers and determine which one is larger. The output should similar to:

Exercise 2:

Write a program which asks the user to enter an exam mark, and then displays whether or not the mark is valid. Hence it will display the grade for that mark.

80-100 A60-79 B40-59 C20-39 D0-19 E

Example of the program output display (user input is in bold):

Enter your mark: 150The exam mark must be between 0 and 100 inclusive.

Enter your mark: 45Your grade is C.

F

Moving Distance

Exercise 3:

Write a program to calculate area of a circle(Note: area= PI*rad2 and Use pow() from the standard library <math.h>). Example of the program output display (user input is in bold):

Exercise 4:

Write a program which asks the user to enter force, angle and meters of moving distance.Note: W=F*S (W=(F cos θ) x s) sample calculation 25 cos 60 ̊̊ x 8meters. Example of the program output display:

θ