Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 CIS 205 Practice Test George Lamperti. 2 1. A word that has a predefined meaning in a C++ program and cannot be used as a variable name is known as.

Similar presentations


Presentation on theme: "1 CIS 205 Practice Test George Lamperti. 2 1. A word that has a predefined meaning in a C++ program and cannot be used as a variable name is known as."— Presentation transcript:

1 1 CIS 205 Practice Test George Lamperti

2 2 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

3 3 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

4 4 2. Indicate if the following are input or output statements: a. cin >> x; b. cout << y; c. cin >> a >> b; d. cout << “hello”;

5 5 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

6 6 3. Which of the following are valid variable names? a. temperature b. cost_of_living c. $deposit d. side2 e. weight_ f. percent%_raise

7 7 3. Which of the following are valid variable names? a. temperature b. cost_of_living c. $deposit d. side2 e. weight_ f. percent%_raise

8 8 4. Memory that loses its contents when the power is removed is ______________memory. a. hot b. empty c. volatile d. fixed

9 9 4. Memory that loses its contents when the power is removed is ______________memory. a. hot b. empty c. volatile d. fixed

10 10 5. A statement that identifies a variable name to a program is known as a _______________ statement. a. declaration b. static c. variable d. definite

11 11 5. A statement that identifies a variable name to a program is known as a _______________ statement. a. declaration b. static c. variable d. definite

12 12 6. When a function is called, the variables or values within the parenthesis are called _____________________. a. parameters b. entries c. arguments d. variables

13 13 6. When a function is called, the variables or values within the parenthesis are called _____________________. a. parameters b. entries c. arguments d. variables

14 14 7. The variables within the function parenthesis in the function heading are called _____________________. a. parameters b. entries c. arguments d. variables

15 15 7. The variables within the function parenthesis in the function heading are called _____________________. a. parameters b. entries c. arguments d. variables

16 16 8. When inputting characters into char variables, the << operation will skip over _____________________. a. periods b. slashes ( / ) c. numbers d. blanks (white spaces)

17 17 8. When inputting characters into char variables, the << operation will skip over _____________________. a. periods b. slashes ( / ) c. numbers d. blanks (white spaces)

18 18 9. Express each value in E-notation (C++ coding convention) a. 0.00000576_______________ b. 576,000,000,000.0_______________

19 19 9. Express each value in E-notation (C++ coding convention) a. 0.00000576__5.76e-6 ______ b. 576,000,000,000.0__5.76e11 ______

20 20 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;

21 21 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

22 22 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

23 23 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

24 24 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

25 25 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

26 26 13. Write a simple for loop segment to output the following array: Int values[20];

27 27 13. Write a simple for loop segment to output the following array: Int values[20]; for(n = 0; n < 20; n++) cout << values[n];

28 28 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

29 29 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

30 30 15. Write a simple for loop segment to allow the user to input new values in the array of question 13.

31 31 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];

32 32 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

33 33 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

34 34 17. Write the section of code that could be used to input and sum a list of exactly 25 values.

35 35 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; }

36 36 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.

37 37 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”;

38 38 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

39 39 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

40 40 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

41 41 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

42 42 Score>=65? cout<<”PASS”cout<<”FAIL” TrueFalse Score>=65? cout<<“PASS”Cout<<“FAIL” True False

43 43 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. ||

44 44 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. ||

45 45 22. A good rule of thumb is always to place _____________________ around both choices of a two-choice if. a. [] b. () c. {} d. //

46 46 22. A good rule of thumb is always to place _____________________ around both choices of a two-choice if. a. [] b. () c. {} d. //

47 47 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. ||

48 48 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. ||

49 49 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

50 50 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

51 51 25. Rewrite the following definite loop using a for statement. Int count; Count = 0; While(count < 25) { cout << “count is “ << count << endl; count++;}

52 52 25. Rewrite the following definite loop using a for statement. Int count; Count = 0; While(count < 25) { cout << “count is “ << count << endl; count++;} for(int count = 0; count < 25; count++) cout << “count is “ << count << endl;

53 53 26. If a function does not return a value, with what type must the function be declared? __________________. __________________.

54 54 26. If a function does not return a value, with what type must the function be declared? void functions do not return a value void functions do not return a value

55 55 27. If SomeFuncA() calls or invokes SomeFuncB(), in what order should these two functions be defined? functions be defined? a. SomeFuncA() then SomeFuncB() b. SomeFuncB() then SomeFuncA() c. the order does not matter

56 56 27. If SomeFuncA() calls or invokes SomeFuncB(), in what order should these two functions be defined? functions be defined? a. SomeFuncA() then SomeFuncB() b. SomeFuncB() then SomeFuncA() c. the order does not matter

57 57 28. The following program is required to calculate the square root of a variable. What must be included for the library function sqrt() to be accessible? must be included for the library function sqrt() to be accessible? ______________________. ______________________. Void main() { float voltage; cin << voltage; cout << “root is: “ << sqrt(voltage);

58 58 28. The following program is required to calculate the square root of a variable. What must be included for the library function sqrt() to be accessible? must be included for the library function sqrt() to be accessible? #include #include Void main() { float voltage; cin << voltage; cout << “root is: “ << sqrt(voltage);

59 59 29. The >> extraction operator reads a character sequence into a string variable until a _____________ ______________ is detected. _____________ ______________ is detected. a. carriage return b. white space c. null operator d. number value

60 60 29. The >> extraction operator reads a character sequence into a string variable until a _____________ ______________ is detected. _____________ ______________ is detected. a. carriage return b. white space c. null operator d. number value

61 61 30. To test if a string variable contains a particular word, the ____________________ function can be used. a. find() b. islike() c. ismember() d. memberof()

62 62 30. To test if a string variable contains a particular word, the ____________________ function can be used. a. find() b. islike() c. ismember() d. memberof()

63 63 31. What is the initial value of a string variable that is not initialized? a. blank b. zero c. empty or null string d. whatever is in that piece of allocated memory

64 64 31. What is the initial value of a string variable that is not initialized? a. blank b. zero c. empty or null string d. whatever is in that piece of allocated memory

65 65 32. The ______________ variable type may be used to hold a sequence of values as opposed to a single value like int or float.

66 66 32. The String variable type may be used to hold a sequence of values as opposed to a single value like int or float.

67 67 33. The getline() function reads a character sequence into a string variable until the end of a ___________________ is reached. a. sentence b. executable line of code c. ; (semicolon) d. line

68 68 33. The getline() function reads a character sequence into a string variable until the end of a ___________________ is reached. a. sentence b. executable line of code c. ; (semicolon) d. line

69 69 End of Final Practice Test


Download ppt "1 CIS 205 Practice Test George Lamperti. 2 1. A word that has a predefined meaning in a C++ program and cannot be used as a variable name is known as."

Similar presentations


Ads by Google