Lab Session 4(Two Dimensional Array with Function)

advertisement
QUESTION 1
Write a program by using modular programming(function) that will:
a) inputData()// Input the data for two dimensional array that have the declaration as
below:
int number[4][5];
b) findAve() // find and return the average value
c) countOdd()// count and display the number of odd number for third row
d) calcSum() // calculate and display the sum value for each column
Please don’t forget to write a main program to call all the functions.
QUESTION 2
Write a program by using modular programming(function) that will:
a) inputData()// Input the data for 5 names into two dimensional array
b) findAveChar() // find and return the average number of character for all names
c) findKarim() // find “Karim” in the array, return 0 if student is not found and return 1
if student is found and display the message “Karim is found” or “Karim is not found”
in the MAIN PROGRAM
Please don’t forget to write a main program to call all the functions.
QUESTION 3
Body Mass Index is the index to determine the health status. Write a program that will
input the height( metres) and weight(kg) for 5 athletes into two dimensional array
called athleteData. The declaration of an array is float athleteData[10][2]. Data
stored in the athleteData array will be used to calculate the BMI for each athlete
based on their height(column 0) and weight(column 1). Then, the calculation for BMI
will be store into one dimensional array called BMIValue.
Formula to calculate BMI = ( Weight in Kilograms / ( Height in Meters x Height in
Meters ) )
BMI Value
Health Status
<=18
Underweight
18,19, 20,21,22,23,24
Normal
25,26,27,28,29
Overweight
>=30
Obese
QUESTION 3(CONT.)
Your program should use these function:
a) InputData()
b) countNormal() //Count and display the number of athlete have a normal health
status
c) countUnderweight()// Count and return the number of athlete is underweight
d) calcAvg()//calculate and return through reference the average weight for all
athlete
e) detHighBMI()// determine and display the highest BMI value
Download
Related flashcards

Elementary mathematics

20 cards

Types of functions

21 cards

History of mathematics

17 cards

Complex analysis

23 cards

Special functions

14 cards

Create Flashcards