Dti2143 dam31303 lab sheet 5

314
-1

Published on

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
314
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
22
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Dti2143 dam31303 lab sheet 5

  1. 1. left0UNIVERSITI TUN HUSSEIN ONN MALAYSIA<br />FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING <br />DTI 2143: COMPUTER PROGRAMMING<br />LAB EXERCISE 4 – MATH.H AND SELECTION intro<br />Exercise 1:<br />Write a program which asks from user for two round numbers and determine which one is larger. The output should similar to:<br /> <br />Exercise 2:<br />FMoving Distance<br />θ<br />Write a program which asks the user to enter force, angle and meters of moving distance.<br />Note: W=F*S (W=(F cos θ) x s) sample calculation 25 cos 60 ̊̊ x 8meters. Example of the program output display:<br />Exercise 3:<br />The following well known sequences of numbers are called the Fibonacci sequence:<br />1,1,2,3,5,8,13,21,34……<br />each number in the sequence is the sum of the previous two numbers. The following Binet formula calculates the value of the nth number in the sequence. Using this formula, write a C program to compute and display the 12th number in the Fibonacci sequence.<br />Use pow() and sqrt() from the standard library <math.h><br />Exercise 4:<br />Write a program that converts a period of time specified by user in seconds, to hours, minutes and seconds. Note: there are 60 seconds in a minute and 3600 seconds in an hour<br />Exercise 5: <br />Write a program which asks the user to enter an age, and then displays according to age entered<br />66-++Elderly <br />22-65Adult<br />12-21Teen<br />4-12Kids<br />2-3Toddlers<br />0-1New Born<br />Example of the program output display (user input is in bold):<br />

×