Practice Quiz CS101
1) Write a C++ function “
Process_List
” to read a list of real numbers a file.
If any of the numbers
are negative skip them but count them and return the count to the calling program, return the
average of the positive numbers.
File handler is passed as an argument to the function. (You need
to decide pass by value or reference is required)
2) Write a C++ function “
Process_Num
” to receive a float number as argument, find and report the
ceil, floor, and rounded number in the form of long type to the calling program.
Ceil means the
next higher whole number, floor mean the previous whole number and round means if the first digit
is 5 or greater then use ceil, if it is smaller than 5 then use the floor.
You may use any system math
function or make your own calculation, just make sure it works for all possible conditions.
Example:
for 3.4234
ceil is 4, floor is 3 and round is 3 ;
for 2345.89997
ceil is 2346, floor is
2345, and rounded is 2346.
3) Assuming the following class is available:
This is the end of the preview. Sign up
to
access the rest of the document.
This note was uploaded on 04/06/2009 for the course CSCI 101L taught by Professor Ghyam during the Spring '07 term at USC.
 Spring '07
 Ghyam
 Computer Programming

Click to edit the document details