C++ Lab 10 Alpha
C++ Lab 10 Alpha
C++ Functions
This lab has been designed to enable students to define their own function and call them in
main(). In this lab students will practice declaring function, defining function and calling
function. Students will also use built-in functions provided in c++. Clear concept about C++
functions has already been provided in the class along with examples.
Objectives:
In this lab, you will practice:
• Function declaration.
• Function definition.
• Calling function.
• Using bulit in functions of c++.
• Defining void functions.
Lab Tasks:
Question # 1:
Write a function that accepts two numbers as arguments and returns maximum number.
Question # 2:
Write a function which accepts three arguments, two numbers and one arithmetic
operator and returns the result.
Question # 3:
Write a function which accepts one integer number as an argument and generates table
of that number.
Question # 4:
Write a function that takes string as input. The function should return the number of
characters in the string.
Question # 5:
Write a program that asks for the user’s height, weight, and age, and then computes
clothing sizes according to the formulas:
• Hat size = weight in pounds divided by height in inches and all that multiplied by 2.9.
• Jacket size = height times weight divided by 288 and then adjusted by adding 1/8 of an
inch for each 10 years over age 30. (Note that the adjustment only takes place after a full
10 years. So, there is no adjustment for ages 30 through 39, but 1/8 of an inch is added
for age 40.)
LAB MANUAL # 10
Course: Computer Programming (CP-107)
Session: 22CP (alpha)
• Waist in inches = weight divided by 5.7 and then adjusted by adding 1/10 of an inch for
each 2 years over age 28. (Note that the adjustment only takes place after a full 2 years.
So, there is no adjustment for age 29, but 1/10 of an inch is added for age 30.)
Use functions for the calculation of hat, jacket and waist size.
Question # 6:
Write a program that applies the following built-in functions to a number, square root,
ceil, floor, round and power.
Question # 7:
Do as directed:
****************