Part I - True/False 1. You should try to avoid using global variables in C++ programs. True 2. All C++ programs have a main function. True 3. Function prototypes should always appear below the main function. False 4. It is dangerous to leave a file open when it is not being used in a program. True 5. The statement infile().close(); would close a file named infile. False 6. The statement file infile; would declare a file pointer. False 7. Random access files are used to store databases. True 8. Adding data to the end of an existing file is called appending. True 9. The compiler directive #include must appear at the top of a program that uses files. False 10. The name infile must be used for a file pointer that is used to read data from a file. False, but it's a good idea Part II - Write valid, efficient C++ code to perform the following tasks. It is NOT necessary to include documentation. However, you MUST use the same exact variable names that are specified. In each separate exercise, you may assume that the necessary variables have been declared unless you are being asked to write an actual declaration statement or a whole program. Use good white space and indentation, so that your answers are neat and easy to read. 1. Write a statement that declares an output file pointer named outfile that would point to the file named TEXT.TXT. ofstream outfile("TEXT.TXT"); 2. Use the open function to open a file named TEXT.TXT for output using a file pointer named outfile. You are to assume that outfile has already been declared as an ofstream file pointer. outfile.open("TEXT.TXT"); 3. Close a file named TEXT.TXT that is pointed to by a file pointer named outfile. outfile.close(); 4. Open a file named TEXT.TXT for appending using a file pointer named outfile. ofstream outfile("TEXT.TXT", ios::app); 5. Write a function named max2 that returns the maximum value of the two integer parameters that are passed to it. int max2(int num1, int num2) { if (num1 > num 2) { return num1; } else { return num2; } } 6. Write a function named ave3 that returns the exact average of three integer parameters that are passed to it. double ave3(int num1, int num2, int num3) { return (num1 + num2 + num3) / 3.0; } 7. Write a complete program that allows the user to input two integers and then displays the larger value. The program should use a function named max2 from a previous exercise to determine which of the two inputed values is the largest. Two int parameters should be passed to the function max2 and the function should return the larger of the two. The main function should then display the largest value. #include #include using namespace std; //Function Declaration Statements double max2(int num1, int num2); int main() { int numA = 0; int numB = 0; int large = 0; cout << "Number A: "; cin >> numA; cout << "Number B: "; cin >> numB; large = max2(numA,numB); cout << "The larger number is " << large << endl; system("pause"); return 0; }// end of main int max2(int num1, int num2) { if (num1 > num2) { return num1; } else { return num2; } } 8. Write a complete program that allows the user to input two integer values. The program must pass those two values to a function named computeAve which returns the average of the two parameters. The main function should then display the final average rounded to the nearest whole number. #include #include using namespace std; //Function Declaration Statements double computeAve(int num1, int num2); int main() { int numA = 0; int numB = 0; double calc = 0.0; cout << "Number A: "; cin >> numA; cout << "Number B: "; cin >> numB; calc = computeAve(numA,numB); cout << "The average is " << int (calc + 0.5) << endl; system("pause"); return 0; }// end of main double computeAve(int num1, int num2) { return (num1 + num2) / 2.0; }