SlideShare a Scribd company logo
1 of 2
left0UNIVERSITI TUN HUSSEIN ONN MALAYSIA<br />FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING <br />BTI 1022: COMPUTER PROGRAMMING<br />LAB EXERCISE 5 Selection and math.h extension<br />Exercise 1:<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 />An example of the program output display (user input is in bold):<br /> Enter duration (secs): 12345<br />12345 seconds is 3 hours, 25 minutes and 45 seconds.<br />Exercise 2:<br />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.<br />80-100A<br />60-79B<br />40-59C<br />20-39D<br />0-19E<br />Example of the program output display (user input is in bold):<br />Enter your mark: 150<br />The exam mark must be between 0 and 100 inclusive.<br />Enter your mark: 45<br />Your grade is C.<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 />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. Use cos() from the standard library <math.h><br />Example of the program output display (user input is in bold):<br />
Bti1022 lab sheet 5

More Related Content

Similar to Bti1022 lab sheet 5

C programming session 03
C programming session 03C programming session 03
C programming session 03
Dushmanta Nath
 
ICT104 Programming Assignment Compiled By Divya Lee.docx
ICT104 Programming Assignment  Compiled By Divya Lee.docxICT104 Programming Assignment  Compiled By Divya Lee.docx
ICT104 Programming Assignment Compiled By Divya Lee.docx
tarifarmarie
 
Week 2PRG 218 Variables and Input and Output OperationsWrite.docx
Week 2PRG 218   Variables and Input and Output OperationsWrite.docxWeek 2PRG 218   Variables and Input and Output OperationsWrite.docx
Week 2PRG 218 Variables and Input and Output OperationsWrite.docx
melbruce90096
 
Dti2143 dam31303 lab sheet 5
Dti2143 dam31303 lab sheet 5Dti2143 dam31303 lab sheet 5
Dti2143 dam31303 lab sheet 5
alish sha
 
C2020-701 IBM Cognos TM1 Analyst
C2020-701 IBM Cognos TM1 AnalystC2020-701 IBM Cognos TM1 Analyst
C2020-701 IBM Cognos TM1 Analyst
Mr TM1
 
C2020-701 IBM Cognos TM1 Analyst
C2020-701 IBM Cognos TM1 AnalystC2020-701 IBM Cognos TM1 Analyst
C2020-701 IBM Cognos TM1 Analyst
Robert Watcke
 
Part 1 Implement a superclass Employee that has the following field.pdf
Part 1 Implement a superclass Employee that has the following field.pdfPart 1 Implement a superclass Employee that has the following field.pdf
Part 1 Implement a superclass Employee that has the following field.pdf
mampbellzumberge517
 
Lecture 3.2.4 C pointer to Structure.pptx
Lecture 3.2.4 C pointer to Structure.pptxLecture 3.2.4 C pointer to Structure.pptx
Lecture 3.2.4 C pointer to Structure.pptx
ravi2692kumar
 

Similar to Bti1022 lab sheet 5 (20)

C programming session 03
C programming session 03C programming session 03
C programming session 03
 
E7
E7E7
E7
 
Cp manual final
Cp manual finalCp manual final
Cp manual final
 
ICT104 Programming Assignment Compiled By Divya Lee.docx
ICT104 Programming Assignment  Compiled By Divya Lee.docxICT104 Programming Assignment  Compiled By Divya Lee.docx
ICT104 Programming Assignment Compiled By Divya Lee.docx
 
Week 2PRG 218 Variables and Input and Output OperationsWrite.docx
Week 2PRG 218   Variables and Input and Output OperationsWrite.docxWeek 2PRG 218   Variables and Input and Output OperationsWrite.docx
Week 2PRG 218 Variables and Input and Output OperationsWrite.docx
 
Programming in c
Programming in cProgramming in c
Programming in c
 
Dti2143 dam31303 lab sheet 5
Dti2143 dam31303 lab sheet 5Dti2143 dam31303 lab sheet 5
Dti2143 dam31303 lab sheet 5
 
C2020-701 IBM Cognos TM1 Analyst
C2020-701 IBM Cognos TM1 AnalystC2020-701 IBM Cognos TM1 Analyst
C2020-701 IBM Cognos TM1 Analyst
 
C2020-701 IBM Cognos TM1 Analyst
C2020-701 IBM Cognos TM1 AnalystC2020-701 IBM Cognos TM1 Analyst
C2020-701 IBM Cognos TM1 Analyst
 
white box testing.ppt
white box testing.pptwhite box testing.ppt
white box testing.ppt
 
Mca 201
Mca 201Mca 201
Mca 201
 
SE-IT JAVA LAB SYLLABUS
SE-IT JAVA LAB SYLLABUSSE-IT JAVA LAB SYLLABUS
SE-IT JAVA LAB SYLLABUS
 
Mi0033 software engineering
Mi0033   software engineeringMi0033   software engineering
Mi0033 software engineering
 
Qm0022 tqm tools and techniques
Qm0022 tqm tools and techniquesQm0022 tqm tools and techniques
Qm0022 tqm tools and techniques
 
Part 1 Implement a superclass Employee that has the following field.pdf
Part 1 Implement a superclass Employee that has the following field.pdfPart 1 Implement a superclass Employee that has the following field.pdf
Part 1 Implement a superclass Employee that has the following field.pdf
 
Chapter 01.PPT
Chapter 01.PPTChapter 01.PPT
Chapter 01.PPT
 
GE3171-PROBLEM SOLVING AND PYTHON PROGRAMMING LABORATORY
GE3171-PROBLEM SOLVING AND PYTHON PROGRAMMING LABORATORYGE3171-PROBLEM SOLVING AND PYTHON PROGRAMMING LABORATORY
GE3171-PROBLEM SOLVING AND PYTHON PROGRAMMING LABORATORY
 
Hiring process of Amazon
Hiring process of AmazonHiring process of Amazon
Hiring process of Amazon
 
cscript_controller.pdf
cscript_controller.pdfcscript_controller.pdf
cscript_controller.pdf
 
Lecture 3.2.4 C pointer to Structure.pptx
Lecture 3.2.4 C pointer to Structure.pptxLecture 3.2.4 C pointer to Structure.pptx
Lecture 3.2.4 C pointer to Structure.pptx
 

More from alish sha (20)

T22016 – how to answer with ubs 9
T22016 – how to answer with ubs 9T22016 – how to answer with ubs 9
T22016 – how to answer with ubs 9
 
July 2014 theory exam (theory)
July 2014 theory exam (theory)July 2014 theory exam (theory)
July 2014 theory exam (theory)
 
Accounting basic equation
Accounting basic equation Accounting basic equation
Accounting basic equation
 
It 302 computerized accounting (week 2) - sharifah
It 302   computerized accounting (week 2) - sharifahIt 302   computerized accounting (week 2) - sharifah
It 302 computerized accounting (week 2) - sharifah
 
It 302 computerized accounting (week 1) - sharifah
It 302   computerized accounting (week 1) - sharifahIt 302   computerized accounting (week 1) - sharifah
It 302 computerized accounting (week 1) - sharifah
 
What are the causes of conflicts (Bahasa Malaysia)
What are the causes of conflicts (Bahasa Malaysia)What are the causes of conflicts (Bahasa Malaysia)
What are the causes of conflicts (Bahasa Malaysia)
 
Lab 9 sem ii_12_13
Lab 9 sem ii_12_13Lab 9 sem ii_12_13
Lab 9 sem ii_12_13
 
Lab 10 sem ii_12_13
Lab 10 sem ii_12_13Lab 10 sem ii_12_13
Lab 10 sem ii_12_13
 
Lab 6
Lab 6Lab 6
Lab 6
 
Lab 5 2012/2012
Lab 5 2012/2012Lab 5 2012/2012
Lab 5 2012/2012
 
Purpose elaborate
Purpose elaboratePurpose elaborate
Purpose elaborate
 
Lab sheet 1
Lab sheet 1Lab sheet 1
Lab sheet 1
 
Test 1 alish schema 1
Test 1 alish schema 1Test 1 alish schema 1
Test 1 alish schema 1
 
Test 1 skema q&a
Test 1 skema q&aTest 1 skema q&a
Test 1 skema q&a
 
Test 1 skema q&a
Test 1 skema q&aTest 1 skema q&a
Test 1 skema q&a
 
Final project
Final projectFinal project
Final project
 
Final project
Final projectFinal project
Final project
 
Attn list test
Attn list testAttn list test
Attn list test
 
Carry markdam31303
Carry markdam31303Carry markdam31303
Carry markdam31303
 
Final project
Final projectFinal project
Final project
 

Bti1022 lab sheet 5

  • 1. left0UNIVERSITI TUN HUSSEIN ONN MALAYSIA<br />FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING <br />BTI 1022: COMPUTER PROGRAMMING<br />LAB EXERCISE 5 Selection and math.h extension<br />Exercise 1:<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 />An example of the program output display (user input is in bold):<br /> Enter duration (secs): 12345<br />12345 seconds is 3 hours, 25 minutes and 45 seconds.<br />Exercise 2:<br />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.<br />80-100A<br />60-79B<br />40-59C<br />20-39D<br />0-19E<br />Example of the program output display (user input is in bold):<br />Enter your mark: 150<br />The exam mark must be between 0 and 100 inclusive.<br />Enter your mark: 45<br />Your grade is C.<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 />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. Use cos() from the standard library <math.h><br />Example of the program output display (user input is in bold):<br />