Modularity Using Functions
Question 1: (Practice)
a. Write a function named check() that has three parameters. The first parameter should accept an integer number, and the second and third parameters should accept a double precision number. The function body should just display the values of data passed to the function when it’s called.
b. Include the function written in Exercise 2a in a working program. Make sure your function is called from main(). Test the function by passing various data to it.
Question 2: (Program)
a. The time in hours, minutes, and seconds is to be passed to a function named totsec().
Write totsec() to accept these values, determine the total number …show more content…
Write a function named ReadOneChar() that reads a key pressed on the keyboard and displays the integer code of the entered character.
b. Include the ReadOneChar() function written for Exercise 10a in a working program.
The main() function should correctly call ReadOneChar() and display the integer the function returns. Test the function by passing various data to it and verifying the returned value.
Question 6: (Program)
a. Write a C++ function named fracpart() that returns the fractional part of any number passed to it. For example, if the number 256.879 is passed to fracpart(), the number
0.879 should be returned.
b. b. Include the function written in Exercise 8a in a working program. Make sure your function is called from main() and returns a value to main() correctly. Have main() use a cout statement to display the returned value. Test the function by passing various data to it and verifying the returned value.
Question 7: (Practice) For the following section of code, determine the data type and scope of all declared variables and symbolic constants on a separate sheet of paper, for example:
Variable or Constant Name
PRICE
Data Type
int
Scope global to main(), roi(), and