Which of the following is a way to put a comment into a C++ program? - Answer /*
comment */
Which of the following are ways to structure statements in most programming
languages(more than one answer is possible here. you need to select them all) -
Answer Sequentially
Loop
Subprogram
Selection
The implementation phase of computer programming involves which one of the
following: - Answer converting the algorithm steps into a programming language
The job of a compiler is to do what? - Answer translate a high level programming
language into machine language
Which of the following is a problem solving technique mentioned in the slides for
chapter 1? - Answer Divide and Conquer
An expression is an arrangement of ____________, _________________ and
______________ that can be evaluated to compute a value of a given type. - Answer
Operations
Literals
Identifiers
From the notes and text, "The set of rules determining the meaning of the instructions
written" is the definition for _______________________ - Answer Semantics
In C++ using strict ANSII standard C++ (and as mentioned for this course), identifiers
can start with what character(s) (more than one answer is possible)? - Answer
Underscores
Letters
In an assignment statement more than 1 variable can be present on the left hand side of
the statement - i.e. x + y =30; is a valid assignment statement - Answer False
Every C++ program must have a function named start - Answer True
The insertion operator << is used to insert information into the output file stream in C+
+? - Answer True
In C++ capitalization of identifiers does not matter because identifiers NAME and name
are considered to be the same identifier by the compiler? - Answer False
,In C++, which of the following operators are valid integer math operators? - Answer /
*
+
%
Which of the following are output file stream manipulators? - Answer setprecission
left
showpoint
Given the C++ code segment below,
string str1, str2;
str1 = "The_third_Quiz_in_CPE211";
str2 = str1.substr(4,8);cout << str2;
What is the string value output by the output statement? - Answer third_Qu
Which of the following is a valid Named Constant Declaration in C++? - Answer const
string NAME = "Elm";
in C++ the following statement will increment num by 1?
num++; - Answer True
The following C++ statement is an example of type casting the integer variable num to a
floating point value:
int num;
float var;
var = (num)float; - Answer False
in C++ the result of the integer division of 6/4 is 1.5? - Answer False
Typically, information is lost when a floating point value is coerced to an integer value. -
Answer True
In C++ the following assignment statement is valid?
num1 = num2 = num3 = num4 = 0; - Answer True
in C++, void functions return a single function value? - Answer False
Which of the following statements will associate the file out.txt with the output file stream
variable outFile? (assume all variables and file streams have been declared correctly
and that all header files are present) - Answer outFile.open("out.txt");
, Which of the following functions is used to associate a file on the hard drive with a
declared file stream variable - Answer open
For the code segment below, what is the value output if the user types in 1 A 2 (select
the best possible answer)
int num1, num2, num3;]
cout << "Enter in 3 integers\n";
cin >> num1 >> num2 >> num3;
cout << num3; - Answer do not know - file stream went into fail state
The statement cin.get(ch); obtains the next character, regardless of what it is, from the
standard input stream cin? (ch is declared as a character variable) - Answer True
In C++ when using the open function, the argument for the open function must be a
string variable - Answer False
The ignore statement cin.ignore(20); will always ignore 20 characters on the input
stream cin? - Answer True
The two character sequence \n is used to represent the new line character in C++ and it
can be stroed in a character variable? - Answer True
The statement getline(cin, str1); reads an entire line ending in a ? into the string variable
str1? - Answer False
Before the code shown below is executed, the input stream (cin) contains the following
characters
(\n represents the new line character) :
500B\nHello 66\n44\n33and the reading marker is on the 5
Using the space provided, write what is output to the terminal by the following segment
of code.
int m = 10;
int x = 20;
string text = "Null";
char ch = 'A';getline(cin,text,'\n');
cin.ignore(5,'\n');
cin >> m >> ch;
cout << m << "-" << ch << "-" << x << "-" << text << endl;
xt << endl; - Answer 66-4-20-500B
In C++ any non-zero integer value is coerced to a boolean value of true - Answer True