You are on page 1of 5

LAB 10

Introduction of functions in C++

Lab Tasks
1. Write a C++ program which creates a Function named calculateBMI in which weight and height is
passed as argument which returns the BMI value.
2. Modify the above program which implements the nested function. In the function calculateBMI, a
function named decisionBMI should be called, which uses the BMI calculated value as input and take
decision that whether you are over-weight, underweight or normal.
Note: weigh in kilogram = weight * 0.45359237.
Hight in feet= inches * 0.0254.
BMI= weight in kilogram/ (hight in fee) ^ 2.
A BMI of 25.0 or more is overweight, while the healthy range is 18.5 to 24.9. BMI applies to most
adults 18-65 years.
3. Implement the above example of calculating sum of an array with a user input generated array.
4. Write a C++ program in which the function named calculateAvg, calculates the average of the sum,
using the returned sum by the function named calculateSum as input arguement.

Task 1
Source Code

CE – 116: COMPUTER PROGRAMMING 1


Output

Task 2
Source Code

CE – 116: COMPUTER PROGRAMMING 2


Output

Task 3
Source Code

CE – 116: COMPUTER PROGRAMMING 3


Output

Task 4
Source Code

CE – 116: COMPUTER PROGRAMMING 4


Output

CE – 116: COMPUTER PROGRAMMING 5

You might also like