The University of Alabama in Huntsville> ECE Department CPE 197 01 Spring 2001 Sample Test II Solution 1. cin.get(chr1); cin.ignore(80, '\n'); cin.get(chr2); cin.ignore(80, '\n'); cin.get(chr3); cin.ignore(80, '\n'); 2. int val1; float val2; cout << "Please enter one integer value and one floating-point value" << endl; cin >> val1 >> val2; 3. #include int val1, val2, val3, val4, val5, val6, val7, val8, val9; ifstream inFile; inFile.open("mydata"); inFile >> val1 >> val2 >> val3 >> val4 >> val5 >> val6 >> val7 >> val8 >> val9; cout << val1 << val2 << val3 << endl; cout << val4 << val5 << val6 << endl; cout << val7 << val8 << val9 << endl; 4. a. no parentheses required b. no parentheses required c. no parentheses required d. !(q && q) 5. 15_No, where _ is a space 6. Level 0 Main Log On Enter a Program Run a Program Level 1 Log On Enter user name Enter password Enter a Program Open Editor Type program Save file Run a Program Compile the program Run the executable 7. a. print #1 \n print #3 b. print #2 \n print #3 c. print #3 8. float x1, y1, x2, y2; float slope; slope = (y2 -y1)/(x2 - x1); 9. a. x is other b. x > 10 c. X > 10 d. x > 10 e. x > 10 f. x > 10 10. if (watts == 15) lumens = 125; else if (watts == 25) lumens = 215; else if (watts == 40) lumens = 500; else if (watts == 60) lumens = 880; else if (watts == 75) lumens = 1000; else if (watts == 100) lumens = 1675; else lumens = -1; end if; 11. Marital status char Annual income float Age int 12. Input: Starting Population Weekly Growth Rate> Output: Ending Population Algorithm: endpop = startpop * growth/100 13.The semicolon after the closing brace.

14. a. 4 b. 2 c. 5 d. 3 e. 1