COP2000 Midterm Exam
These are operators that add and subtract one from their operands
++ and - -
What is the value of x after the following code executes? Int x=0; int y=5; int z=4; x=x+y+z++2;
0
Which of the following is NOT a valid C++ identifier?
1user
What will the code display? Int x=0 For (Int count=0; count <3;count++) x+-count; cout << x << endl;
3
What will the following code display? Int number - 6; Int X=0; X= -- number; cout << x << endl;
5
What operators is used first? while (x++<10)
<
A statement that causes a loop to terminate early is
Break
Which data type typically requires only one byte of storage?
Char
The ____ _________ causes a program to wait until information is typed at the keyboard and the [Enter] key is passed.
Cin Object
Which steps uncovers any syntax errors in your program?
Compiling
The __________ ______ decodes an instruction and generates an electronic signal.
Control Unit
The ______ loo[ is a good choice when you know how many times you want the loop to iterate in advance of entering the loop.
For
Which of the following must be included in any program that use the cout object?
Iostream
What is TRUE about the following statement? cout <<setw(4)<<num4<<"";
It allows four spaces for the value in num4
Words that have a special meaning and may be used for their intended purpose are know as
Key Words
Which of the following is NOT a common input device?
Printer
This is used in a program to mark the beginning or ending of a statement, or separate items in a list.
Punctuation
What will the following code display? cout << "Rose" << "are red""; cout << "and" << "Violets/n" cout << "are" << "blue" << endl;
Rose are redand Violets/nareblue
Programs are normally stored in __________ ___________ and loaded into the main memory as needed.
Secondary Storage
A special value that marks the end of a list of values is a
Sentinel
Computer programs are also know as
Software
When a programmer saves to a file the statements, her or she writes to create a program the statements are ________ _____.
Source Code
This a complete instruction that causes the computer to perform some action
Statement
In a C++ program, two slash marks indicate
The beginning of a comment
What will the following code display? int number=23; cout << "The number is"" << "numer" << endl;
The number is number
When C++ is working with an operator, it strives to convert operands to the same type. This is known as _________.
Type Coercion
A ________ represents a storage location in the computers memory.
Variable
A file _________ is a small holding section of memory that file bound information is first written to.
buffer
Which is the following will allow the user input the values 15 and 20 and have them stored in variables named base and height respectively?
cin >> base >> height;
To use the rand() function, you must include the _________ headerfile
cstdlib
A character literal is ____________________________________________________, whereas a string literal is _______________________________________________________________.
enclosed in single quotation marks, enclosed in double quotation marks.
In a cout statement, which of the following will advance the output position in the beginning of the next line?
endl or \n
________ reads a line inputs including leading and embedded spaces, and stores it in a string object.
getline
A loop that is inside another loop is called a
nested loop
Assuming outFile is a file stream object and number is a variable, which statement writes the contents of number to the file associated with outFile?
outFile << number;
A __________ is a set of instruction that the computer follows to solve a problem.
program
Which of the following functions will return the value of X, rounded to the nearest whole number
round(x)
A variable definition tells the computer
the variables name and the type of data it will hold.