690 likes | 798 Views
CIS 205 Practice Test. George Lamperti. 1. A word that has a predefined meaning in a C++ program and cannot be used as a variable name is known as a _____________________ . a. ID b. reserved word c. non-variable word d. word key.
E N D
CIS 205 Practice Test George Lamperti
1. A word that has a predefined meaning in a C++ program and cannot be used as a variable name is known as a _____________________ . a. ID b. reserved word c. non-variable word d. word key
1. A word that has a predefined meaning in a C++ program and cannot be used as a variable name is known as a _____________________ . a. ID b. reserved word c. non-variable word d. word key
2. Indicate if the following are input or output statements: a. cin >> x; b. cout << y; c. cin >> a >> b; d. cout << “hello”;
2. Indicate if the following are input or output statements: a. cin >> x; Input b. cout << y; Output c. cin >> a >> b; Input d. cout << “hello”; Output
3. Which of the following are valid variable names? a. temperature b. cost_of_living c. $deposit d. side2 e. weight_ f. percent%_raise
3. Which of the following are valid variable names? a. temperature b. cost_of_living c. $deposit d. side2 e. weight_ f. percent%_raise
4. Memory that loses its contents when the power is removed is ______________memory. a. hot b. empty c. volatile d. fixed
4. Memory that loses its contents when the power is removed is ______________memory. a. hot b. empty c. volatile d. fixed
5. A statement that identifies a variable name to a program is known as a _______________ statement. a. declaration b. static c. variable d. definite
5. A statement that identifies a variable name to a program is known as a _______________ statement. a. declaration b. static c. variable d. definite
6. When a function is called, the variables or values within the parenthesis are called _____________________. a. parameters b. entries c. arguments d. variables
6. When a function is called, the variables or values within the parenthesis are called _____________________. a. parameters b. entries c. arguments d. variables
7. The variables within the function parenthesis in the function heading are called _____________________. a. parameters b. entries c. arguments d. variables
7. The variables within the function parenthesis in the function heading are called _____________________. a. parameters b. entries c. arguments d. variables
8. When inputting characters into char variables, the << operation will skip over _____________________. a. periods b. slashes ( / ) c. numbers d. blanks (white spaces)
8. When inputting characters into char variables, the << operation will skip over _____________________. a. periods b. slashes ( / ) c. numbers d. blanks (white spaces)
9. Express each value in E-notation (C++ coding convention) a. 0.00000576 _______________ b. 576,000,000,000.0 _______________
9. Express each value in E-notation (C++ coding convention) a. 0.00000576 __5.76e-6 ______ b. 576,000,000,000.0 __5.76e11 ______
10. What values would be assigned to the int variable x in each case? a. x = 5 + 7.6; b. x = 5 / 7.6; c. x = 7 / 5; d. x = 7.6 / 5.5;
10. What values would be assigned to the int variable x in each case? a. x = 5 + 7.6; 13 b. x = 5 / 7.6; 0 c. x = 7 / 5; 1 d. x = 7.6 / 5.5; 1
11. The integer constant or variable within brackets used to reference a particular one-dimensional array cell is called the array __________________________. a. counter b. indicator c. index or subscript d. modifier
11. The integer constant or variable within brackets used to reference a particular one-dimensional array cell is called the array __________________________. a. counter b. indicator c. index or subscript d. modifier
12. Do array parameter declarations in a function need to use the & operator if the array is to be changed or modified? a. yes – arrays are never passed by reference b. no – arrays are automatically passed by reference
12. Do array parameter declarations in a function need to use the & operator if the array is to be changed or modified? a. yes – arrays are never passed by reference b. no – arrays are automatically passed by reference
13. Write a simple for loop segment to output the following array: Int values[20];
13. Write a simple for loop segment to output the following array: Int values[20]; for(n = 0; n < 20; n++) cout << values[n];
14. If an integer array is partially initialized, the unspecified cells will be set to _____________________. a. zero (0) b. blanks c. nulls d. none of the above
14. If an integer array is partially initialized, the unspecified cells will be set to _____________________. a. zero (0) b. blanks c. nulls d. none of the above
15. Write a simple for loop segment to allow the user to input new values in the array of question 13.
15. Write a simple for loop segment to allow the user to input new values in the array of question 13. for(n = 0; n < 20; n++) cin >> values[n];
16. A loop where the exact number of repeats or repetitions is not known is called an __________________ loop. a. undefined b. ill-defined c. indefinite d. counted
16. A loop where the exact number of repeats or repetitions is not known is called an __________________ loop. a. undefined b. ill-defined c. indefinite d. counted
17. Write the section of code that could be used to input and sum a list of exactly 25 values.
17. Write the section of code that could be used to input and sum a list of exactly 25 values. count = 0.0; sum = 0.0; while(count < 25.0) { cin >> value; sum = sum + value; count = count + 10; }
18. Write a section of code that could be used to output YES if the variable cost is greater than 100.0 or output NO if cost is less than or equal to 100.0.
18. Write a section of code that could be used to output YES if the variable cost is greater than 100.0 or output NO if cost is less than or equal to 100.0.if(cost > 100.0) cout << “YES”; else cout << “NO”;
19. If the user is to enter a sentinel value at the end of an indefinite list of vaues, the programmer would use an ____________________ loop. a. indefinite b. undefined c. counted d. ill-defined
19. If the user is to enter a sentinel value at the end of an indefinite list of vaues, the programmer would use an ____________________ loop. a. indefinite b. undefined c. counted d. ill-defined
19. If the user is to enter a sentinel value at the end of an indefinite list of values, the programmer would use an ____________________ loop. a. indefinite b. undefined c. counted d. ill-defined
20. Draw a symbolic diagram or flowchart of a program segment that could be used to output the message PASS or FAIL for a given test score. Assume 65 and above is a passing score
True Score>=65? False cout<<”PASS” cout<<”FAIL” False True Score>=65? cout<<“PASS” Cout<<“FAIL”
21. Which Boolean operator should be used in a condition to test if either variable a or variable b is true? _____________________. a. && b. ! c. == d. ||
21. Which Boolean operator should be used in a condition to test if either variable a or variable b is true? _____________________. a. && b. ! c. == d. ||
22. A good rule of thumb is always to place _____________________ around both choices of a two-choice if. a. [] b. () c. {} d. //
22. A good rule of thumb is always to place _____________________ around both choices of a two-choice if. a. [] b. () c. {} d. //
23. Which Boolean operator should be used in a condition to test if both variable a and variable b is true? a. && b. ! c. == d. ||
23. Which Boolean operator should be used in a condition to test if both variable a and variable b is true? a. && b. ! c. == d. ||
24. Consider the following for loop: for(n=0; n<10; n++) cout << “hello” << endl; How many different lines will the above loop produce? a. 9 lines b. 11 lines c. 10 lines d. 0 lines
24. Consider the following for loop: for(n=0; n<10; n++) cout << “hello” << endl; How many different lines will the above loop produce? a. 9 lines b. 11 lines c. 10 lines d. 0 lines