<p> CSDP 221 QUIZ #3 SPRING 2012</p><p>1. Write a statement(s) for computing the remainder of the division of int num1 with int num2 and storing the result in int answer. (2)</p><p>2. What is the result of the following typecasting statements? (2)</p><p>A) int(7.4)</p><p>B) float(6)</p><p>C) float(10/6)</p><p>D) float(10)/float(6) </p><p>3. A function prototype is a declaration of a function that omits the function body but does specify the function's return type, name, and argument types. Write function prototypes for the following: (5)</p><p>A) A void function (never returns a value to the caller) named Print with one float argument.</p><p>B) A void function named Hello with one float argument and one string argument.</p><p>C) A float returning function named taxCalculator with two float arguments.</p><p>D) An integer returning function named Bonus with no arguments.</p><p>E) A void function named ForFun with no arguments. 4. Write a statement for printing the value in string variable name in 10 character positions. (1)</p><p>5. Suppose the input data are entered as follows: (2) 10 20 50 60 70 80 The input statements that read it are cin >> a >> b >> c; cin >> d; What are the contents of the variables a, b, c, and d after the statements have executed?</p><p>PLEASE TURN OVER 6. Suppose the input data are entered as follows: (1) 10 20 30 40 50 60 70 80 The input statements that read it are cin >> a >> b >> c; cin >> d >> e >> f; cin >> a >> b; What are the contents of the variables a and b after the statements have executed?</p><p>7. Write C++ statements for (3)</p><p>A) Declaring two string variables FName and LName.</p><p>B) Prompting the user to enter his/her first name and last name.</p><p>C) Getting the first name and last name using cin into FName and LName.</p><p>8. Write C++ statements for getting values into three character variables named c1, c2, and c3 using the get function. (3) 9. Write a C++ statement for ignoring (or skipping) 10 characters or until ‘#’ from the standard input stream (keyboard). (2)</p><p>10. Write C++ statements for getting values into string variables city and state using the getline function. (2)</p><p>11. Write C++ statements for (2)</p><p>A) Declaring an input file stream variable (name is your choice).</p><p>B) Opening a file named “input.txt” using the above variable.</p><p>Maximum Points: 25</p>
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages3 Page
-
File Size-