Course: CPS 120: Introduction to Computer Science ~ Master (Aug/2015) OLD

Q: Assigning a string value to an integer variable will cause a compilation error.
- True
- False
A: False

Q: The cout statement can read and write variables.
- True
- False
A: False

Q: Expression (5 / 8) is equal to 0.625.
- True
- False
A: False

Q: A constant is similar to a variable but its value does not change while a program executes.
- True
- False
A: True

Q: Data beyond the size of an array can still be processed in C++ but is considered invalid or junk.
- True
- False
A: True

Q: Which of the following is included in Visual Studio?
- Text editor for writing code
- Graphical editor for developing a graphical user interface (GUI)
- Debugger for stepping through code, setting breakpoints, and watching variables
- All of the above
A: All of the above

Q: What is the result of each of the expression 40 / 3 % 3 = ?
A: 1, 1.0

Q: What is the result of each of the expression 46 % 7 = ?
A: 4, 4.0

Q: What is the result of each of the expression 3 + 3 * 3 / 3.0 = ?
A: 6, 6.0

Q: What is the result of each of the following expression 2 * 5 – 2 / 4 =?
A: 10, 10.0

Q: Write code to add all the even numbers from 1 to 100.
Feedback: for (sum = 0, i = 0; i <= 100; i += 2) sum += i;

Q: Write code to ask the user to input a number and continue asking until they give you a positive value.
Feedback: do { cout << "Enter a non-positive number"; cin >> n; } while (n > 0);

Q: Write code to read values from screen and sum all the negative ones until a value of 999 is read in.
Feedback: cout << "Enter a number, use -999 to stop"; cin >> n; while (n != 999) { if (n < 0) sum += n; cout << "Enter a number, use -999 to stop"; cin >> n; }

Q: The following C++ variables are invalid except:
- first name
- double
- count em
- Int
- 3rockAndRoll
A: Int

Q: What is the result of each of the expressions 40 / 3 % 3 =?
A: 1 / 1.0 / one

Q: What is the result of each of the following expression 46 % 7 =?
A: 4 / 4.0 / four

Q: What is the result of each of the following expression 3 + 3 * 3 / 3.0 =?
A: 6 / 6.0 / six

Q: What is the result of each of the following expression 2 * 5 – 2 / 4 = ?
A: 10 / 10.0 / ten

Q: What does FTP stand for? (spelling counts)
A: File Transfer Protocol

Q: Is it true that an OR gate accepts one input value and produces two output values?
- True
- False
A: False

Q: What is the hexadecimal value that represents the decimal number 81?
A: 51

Q: If you have a number 124 in base 6, show how would you convert it to base 10?
A: 1x36 + 2x6 + 4x1 = 52 / 1x36+2x6+4x1=52 / 1 x 36 + 2 x 6 + 4 x 1 = 52

Q: What is the two’s complement of the binary number 00101110?
A: 11010010

Q: What is the hex result of subtracting the hex numbers C43A – A9AB?
A: 1A8F

Q: What does USB stand for? (spelling counts)
A: Universal Serial Bus

Q: Show a trace of the binary search algorithm (not binary search tree) looking for number 230. (67, 89, 93, 94, 121, 123, 230, 250, 251, 253, 255, 300, 301, 305, 310, 320)?
Feedback: Go to location 7 first (250) then location 3 next (94) then location 5 next (123) then location 6 next (230) found

Q: Name 4 output devices?
Feedback: Fax, Printer, Projector, Headphones, Monitor, Plotter

Q: Name 4 input devices?
Feedback: Mouse, Microphone, Touch Screen, Fax, Scanner, Laser Pen

Q: Show each state of the list using the Selection sort to get to the sorted list:

14

8

10

2

8

32

17
Feedback: 14 2 2 2 2 2 2 8 8 8 8 8 8 8 10 10 10 8 8 8 8 2 14 14 14 10 10 10 8 8 8 10 14 14 14 32 32 32 32 32 32 17 17 17 17 17 17 17 32

Q: A table may have zero records.
- True
- False
A: True

Q: A record is made up of one or more tables.
- True
- False
A: False

Q: The SQL SELECT statement may be used to update data within a table.
- True
- False
A: False

Q: Write the SQL SELECT statement to get all the records and fields from table Cities. SELECT * FROM Cities;

Q: Write the SQL SELECT statement to get all the records and fields Name and Price from table Appliances. SELECT Name, Price FROM Appliances;

Q: Write the SQL SELECT statement to get all the records and fields Name and Price from table Appliances where the Price is greater than 100. SELECT Name, Price FROM Appliances WHERE Price > 100;

Q: In the following 3 exercises, you will use the data in the table shown below:

- (a)  Write an SQL query to list the City and the State of all companies that start with the word "South" and have more than 100 employees from the table above.
- (b)  Write an SQL query to list all Members table's fields of all membership that expires the last quarter of year 2005.
- (c) Write an SQL query to list MemberID, City, and ExpDate for those members in AL and membership type is neither Y nor B.
Feedback: (a) SELECT City, State FROM members WHERE company like "*South" AND NumEmployees > 100 (b) SELECT * FROM members WHERE ExpDate BETWEEN #9/1/2005# AND #12/31/2005# (c) SELECT MemberID, City, ExpDate FROM members WHERE state = 'AL' AND NOT(MType = 'Y' OR MType = 'B')

Q: Write the following queries using the tables' structures below:

a)      Create a Query using the Members table below. Include only Member ID, Company, and Member Type.

b)      Create a Query using the Contacts table below. Display only the contacts whose last name starts with the letter H. Include all fields.

c)      Create a Query using both tables below to display the Member ID, Company, State, and Telephone for those who lives in GA state.
Feedback: (a) SELECT MemberID, Company, MemberType FROM members (b) SELECT * FROM contacts WHERE Contact_Name like "H*" (c) SELECT Member ID, Company, State, Telephone FROM members, contacts WHERE members.MemberID = contacts.MemberID AND State = "GA"

Q: A reserved word can be used as a variable name.
- True
- False
A: False

Q: To use cout and cin, the program must include the library <oistream>.
- True
- False
A: False

Q: If a program compiles successfully, it will produce correct results.
- True
- False
A: False

Q: Suppose that x is an int variable, y is a double variable and ch is a char variable and the input is:

15A 73.2

After the following statement executes

cin >> x >> ch >> y;
- x = 15, ch = 'A', y = 73.2
- x = 15, ch = 'A', y = 73.0
- This statement results in an error because there is no space between 15 and A
- None of these
A: x = 15, ch = 'A', y = 73.2

Q: What is the output of the following statements?

cout << “Hello” << endl << “Jame’s”;
- Hello Jame’s
- HelloJame’s
- Hello
James
- Hello
Jame’s
A: Hello
Jame’s

Q: How many times will the following while loop be executed?

set the jar status to ‘open’
set the time to ‘5’
while the jar is open or the time is less than 12
increase time by 2
end the while loop
- one time
- two times
- three times
- four times
- None of the above.
A: None of the above.

Q: What is the final result of the expression  8  %  3  +  3  *  5  /  2 ?
- 9
- 8
- 9.5
- 4
- None of the above.
A: 9

Q: What data type would you use for the value “9991234567” not 9991234567?
- int
- byte
- string
- long
A: string

Q: What is the output of the following code?
- HelloThere
- HelloThereHelloThere
- There
- HelloHelloThere
- No output will be produced.
A: HelloThere

Q: Even thought the indentation is bad, the code still works. What is the output of the following code fragment?
- !
- &
- $
- !&
- !$
A: &

Q: What is the final value of sum after the  for loop is finished?
- 11
- 26
- 57
- 12
- None of the above.
A: None of the above.

Q: What is the output of the following code fragment?
- 7
- 5
- Infinite Loop
- Compilation (syntax) error
- None of the above.
A: 5

Q: Suppose that the input is

38     42     70     4     -1   5    5    10

What is the output of the following code fragment? Assume all the variables are properly declared.
- Total is = 153
- Total is = 158
- Total is = 111
- Total is = 154
- None of the above
A: None of the above

Q: Which line would you change to correct the following code fragment so that it finds the sum of 10 numbers? Assume all the variables are properly declared.
- change the condition in line 3 to (Count <= 10)
- change line 2 to Count = 1;
- move line 7 before line 5
- a or b
- It is already correct.
A: It is already correct.

Q: What is the output of the following code fragment?
- 1,  3,  5,  7,  9,
- 0,  2,  2,  2, 2,
- 2,  4,  6,  8,
- 2,  2,  2,  2,  2,
- 2,  2,  2,  2,
A: 2,  2,  2,  2,  2,

Q: The statement ¬ (a∧¬ b) is equivalent to which of the following six statements?

A.   a∧b | C.   ¬ a∧b | E.   a∧¬ b
B.   a∨b | D.   ¬ a∨b | F.   a∨¬ b
A: D
If right: EXCELLENT
If wrong: If you missed this please study the topic on BOOLEAN LOGIC

Q: Evaluate the expression:
A: 155
If right: Good Job!
If wrong: If you missed this please review the topic on ORDER OF OPERATIONS section A .

Q: Evaluate the expression:
A: 3 / 3.00
If right: Great Job
If wrong: If you missed this please study the topic on ORDER OF OPERATIONS

Q: Evaluate the expression:
A: 25 / 25.00
If right: Great Job
If wrong: If you missed this please study the topic on ORDER OF OPERATIONS

Q: Find the product of:

(Express as a mixed number)
A: 62 13/56 / 62 13 / 56
If right: Great Job!
If wrong: If you missed this please study the topic on NUMERIC EXPRESSIONS

A: -14 / -14.00
If right: Great Job
If wrong: If you missed this please study the topic on ORDER OF OPERATIONS

Q: Convert CEA_15 to base 10. Note that base 15 uses the symbols 0123456789ABCDE.
A: 2920
If right: Great Job
If wrong: If you missed this please study the topic on NUMBER BASES

Q: Convert 567_8 to base 10.
A: 375
If right: Great Job
If wrong: If you missed this please study the topic on NUMBER BASES

Q: Convert 10101011_2 to base 10
A: 171
If right: Great Job
If wrong: If you missed this please study the topic on NUMBER BASES

Q: Convert the base ten value 245 to octal.
A: 365
If right: Great Job
If wrong: If you missed this please study the topic on NUMBER BASES.

Q: Convert the base ten value 159 to binary.
A: 10011111
If right: Great Job
If wrong: If you missed this please study the topic on NUMBER BASES

Q: Convert the dot notation value 34.19.57.119 to a hexadecimal number.
A: 22133977
If right: Great Job
If wrong: If you missed this please study the topic on NUMBER BASES

Q: Convert the hexadecimal value B504 to binary.
A: 1011010100000100
If right: Excellent
If wrong: If you missed this please study the topic on NUMBER BASES

Q: Convert the hexadecimal value 732D053A to dot notation.
- 115.45.5.58
- 115.54.5.58
- 155.54.5.56
- 105.45.5.58
A: 115.45.5.58
If right: Excellent
If wrong: If you missed this please study the topic on NUMBER BASES

Q: Compute 44 % 8
A: 4 / four
If right: Correct
If wrong: If you missed this please study the topic on MODULAR OPERATIONS.

Q: Compute the gcf of 4845 and 3315:
A: 255 / 255.0
If right: Great
If wrong: If you missed this please study the topic on MODULAR OPERATIONS

Q: Compute the gcf of 2639 and 5797:
A: 1 / 1.0
If right: Great!
If wrong: If you missed this study the topic on Modular Operations

Q: Compute the lcm of 18 and 50:
A: 450 / 450.0
If right: Great!
If wrong: If you missed this please study the topic on MODULAR OPERATIONS

Q: Compute 18! / 15!   :
A: 4896 / 4896.0
If right: Great!
If wrong: If you mssed this question study the section on MODULAR OPERATIONS

Q: Evaluate the expression:
A: 2.87
If right: Great Job
If wrong: Try again and remember. using decimals, round to the nearest two decimals

Q: Evaluate the expression:
A: 3 / 3.00
If right: Great Job
If wrong: If you missed this please study the topic on ORDER OF OPERATIONS

Q: Evaluate the expression:
A: -4.33
If right: Great Job
If wrong: Try again and remember. using decimals, round to the nearest two decimals

Q: Evaluate the expression:
A: 25 / 25.00
If right: Great Job
If wrong: If you missed this please study the topic on ORDER OF OPERATIONS

Q: Evaluate the expression:
A: -11 / -11.00
If right: Great Job
If wrong: Try again and remember. using decimals, round to the nearest two decimals

A: 880 / 880.00
If right: Great Job
If wrong: Try again

Q: Which of the following letters cannot be represented extactly on a calculator that holds at most 6 digits? (Use the letters to state answer. If choosing more than one letter, seperate by a comma and no space. Such as T,S,P)

P: 8/127     Q: 127/8      R: 3/4      S: 4/3      T: 47/25
A: P,S
If right: Great Job
If wrong: Sorry, try again. Hint, there are 2

Q: Which of the following deomonstrate integers are not closed under the operation of division?

Express your answers using the letters P, Q and R. If more than one answer is chosen, seperate by a comma
A: Q,S / Q , S
If right: Great Job!
If wrong: Sorry

Q: We know that However, on a calculator that holds and displays at most 5 digits gives the result 0.24242. Find the magnatude of the error of result
- 0.0000042424242...
- 0.424242...
- 0.00424242...
A: 0.0000042424242...
If right: Great Job
If wrong: Sorry

Q: Convert 857_9 to base 10,
A: 700
If right: Great Job
If wrong: Sorry

Q: Convert DFE_16 to base 10. Note that base 16 uses the symbols 0123456789ABCDEF.
A: 3582
If right: Great Job
If wrong: Sorry

Q: Convert the base ten value 1124 to base 12.
A: 798
If right: Great Job
If wrong: Sorry

Q: Convert the base ten value 3226 to hexadecimal. Answer = [x] _16
A: C9A
If right: Great Job
If wrong: Sorry

Q: Convert the binary value 0010100001110110 to hexadecimal.
A: 2876
If right: Great Job
If wrong: Sorry

Q: Compute 109 % 15:
A: 4 / four
If right: correct
If wrong: sorry

Q: Compute 304 % 22:
A: 18 / eighteen
If right: Correct
If wrong: Sorry

Q: Compute the gcf of 3300 and 20100:
A: 300 / 300.0
If right: Great
If wrong: Sorry

Q: Compute the lcm of 90 and 770:
A: 6930 / 6930.0
If right: Great!
If wrong: Sorry

Q: Compute the lcm of 126 and 60:
A: 1260 / 1260.0
If right: Great!
If wrong: Sorry

Q: Compute 7!  :
A: 5040 / 5040.0
If right: Great!
If wrong: Sorry

Q: Evaluate the expression:
A: 2.87
If right: Great Job
If wrong: Try again and remember. using decimals, round to the nearest two decimals

Q: Evaluate the expression:
A: 3 / 3.00
If right: Great Job
If wrong: If you missed this please study the topic on ORDER OF OPERATIONS

Q: Evaluate the expression:
A: -4.33
If right: Great Job
If wrong: Try again and remember. using decimals, round to the nearest two decimals

Q: Evaluate the expression:
A: 25 / 25.00
If right: Great Job
If wrong: If you missed this please study the topic on ORDER OF OPERATIONS

Q: Evaluate the expression:
A: -11 / -11.00
If right: Great Job
If wrong: Try again and remember. using decimals, round to the nearest two decimals

A: 880 / 880.00
If right: Great Job
If wrong: Try again

Q: Which of the following letters cannot be represented extactly on a calculator that holds at most 6 digits? (Use the letters to state answer. If choosing more than one letter, seperate by a comma and no space. Such as T,S,P)

P: 8/127     Q: 127/8      R: 3/4      S: 4/3      T: 47/25
A: P,S
If right: Great Job
If wrong: Sorry, try again. Hint, there are 2

Q: Which of the following deomonstrate integers are not closed under the operation of division?

Express your answers using the letters P, Q and R. If more than one answer is chosen, seperate by a comma
A: Q,S / Q , S
If right: Great Job!
If wrong: Sorry

Q: We know that However, on a calculator that holds and displays at most 5 digits gives the result 0.24242. Find the magnatude of the error of result
- 0.0000042424242...
- 0.424242...
- 0.00424242...
A: 0.0000042424242...
If right: Great Job
If wrong: Sorry

Q: Compute 109 % 15:
A: 4 / four
If right: correct
If wrong: sorry

Q: Compute 304 % 22:
A: 18 / eighteen
If right: Correct
If wrong: Sorry

Q: Compute the gcf of 3300 and 20100:
A: 300 / 300.0
If right: Great
If wrong: Sorry

Q: Compute the lcm of 90 and 770:
A: 6930 / 6930.0
If right: Great!
If wrong: Sorry

Q: Compute the lcm of 126 and 60:
A: 1260 / 1260.0
If right: Great!
If wrong: Sorry

Q: Compute 7!  :
A: 5040 / 5040.0
If right: Great!
If wrong: Sorry

Q: Convert 857_9 to base 10,
A: 700
If right: Great Job
If wrong: Sorry

Q: Convert DFE_16 to base 10. Note that base 16 uses the symbols 0123456789ABCDEF.
A: 3582
If right: Great Job
If wrong: Sorry

Q: Convert the base ten value 1124 to base 12. Answer = [x] _12
A: 798
If right: Great Job
If wrong: Sorry

Q: Convert the base ten value 3226 to hexadecimal. Answer = [x] _16
A: C9A
If right: Great Job
If wrong: Sorry

Q: Convert the binary value 0010100001110110 to hexadecimal. Answer = [x]  _16
A: 2876
If right: Great Job
If wrong: Sorry