Expert Answers

CLICK HERE TO DOWNLOAD THIS ANSWER  INSTANTLY $28 Only

 

(TCO 13) Text files are what type of file?
Sequential
Random access
Binary
Consecutive

(TCO 13) What do the following statements accomplish?
ofstream theFile;
theFile.open( myFile.txt , ios::app);
Opens myFile in read mode
Opens myFile in append mode
Creates an empty file named myFile
Opens a file in input mode to write to

(TCO 13) The function used to determine whether an entire sequential access file has been read is called _____.
close() function
eof() function
open() function
None of the above

(TCO 13) Which of the following functions should be used to determine if a file was successfully opened?
is_active
is_open
is_closed
is_ready

(TCO 12) Which is not a reason that pointers are valuable?
Pointers allow for faster access to array elements.
Pointers speed the process of passing objects like classes to functions.
Pointers allow function to be passed as an argument to other functions.
Pointers involve a great deal of overhead when used in conjunction with arguments.

(TCO 11) If n represents the size of an array, the index of the last element in the array would be _____.
n-2
n
n-1
Cannot be determined

(TCO 11) When working with an array, the easiest way to traverse or visit all elements of the array is to _____.
use a loop statement
sort the array and read it
do a binary search
use sequential coding

(TCO 11) In the following array, what is the value of table[0][0]?
int table[4][3]={3,7,0,2,4,9,8,1,3,6,5,4};

3
7
2
4

(TCO 10) Bug errors are _____ errors.
asp.net
syntax
binary
logic

(TCO 9) The programmer determines the fields and methods of an object and creates the _____ code.
class
procedural
module
None of the above
(TCO 9) The class _____ starts with the word "Class" followed by the name of the class.
body
definition
return
members
(TCO 9) You should declare a data field private by using the _____ keyword.
clandestine
concealed
private
Data fields cannot be private.
(TCO 9) What has exactly the same name as the defining class?
Constructor
Inheritance
Accessor
Polymorphism
(TCO 8) When a function does not return a value, it is called a _____ function.
nill
noid
void
zero-based
(TCO 7) What is wrong with this call statement?
PrintName(string name);
It is missing void.
The data type should be removed.
The semicolon should be removed.
Nothing is wrong with it.
(TCO 7) What does it mean to say that a variable is local to a function?
main() can use it whenever it wants to, but no other function can see or use it.
Only the function where the variable is declared can see and use it.
No functions can see or use it.
Every function can use it.
(TCO 7) What is a logical use for global variables?
You don't have to keep passing variables between functions.
They make programs easier to write.
When working in a large group, there are no hassles with naming variables.
Mathematical constants

(TCO 6) Debugging is like being a(n) _____.
accountant
attorney
detective
police officer

(TCO 5) Which of the following does counter-controlled repetition require?
An initial value
A condition that tests for the final value
An increment or decrement by which the control variable is modified each time through the loop
All of the above
(TCO 5) A loop that falls entirely within the body of another is a(n) _____ loop.
outer
nested
parent
restricted
(TCO 5) How many times will this for loop execute?
for (int i = 10; i > 0; --i)
Seven
Nine
10
Eight


Question 7.7. (TCO 4) Input values should always be checked for _____.
appropriate range
reasonableness
division by zero if division is taking place
All of the above


Question 8.8. (TCO 4) Consider the following segment of code.
if(apple == 5)
cout<<"You got five apples!"<<endl;
else
cout<<"You do not have five apples!\n";
cout<<"The end of the program is reached.";
What will be the output on screen if apple is 5?
You do not have five apples!
The end of the program is reached.
You got “five” apples!
You do not have five apples!


Question 9.9. (TCO 4) What keywords are used to construct a switch statement?
case, jump, break, default
switch, case, break, default
break, default, case, goto
switch, case, break, else


Question 10.10. (TCO 3) What is the value of x after the following statement?
float x;
x = 2 * 5 + (3 + 1)/ 5.0 ;
10.8
10.0
1.0
0.8

(TCO 2) In which namespace can cout and cin be found?
<upstream>
::
math
std

Question 12.12. (TCO 2) What is the extension name for a C++ source code file?
.h
.cpp
.exe
.class


Question 13.13. (TCO 2) C++ comments are represented by which characters?
// and /* */
:: and //
// and >>
>


Question 14.14. (TCO 1) _____ enhances a programmer's productivity by providing editing, compiling, and debugging in one software package.
MRE
C++
Compiler+
IDE


Question 15.15. (TCO 2) Which of the following statements will output “Hello World”?
cout
cin
Print Queue
Print Line

Provide a C++ code segment that reads data from a text file using a while loop. The file name should be c:\finalexam.txt. You need to check that the file is open and test for eof in the loop.

Create a code segment that defines a class definition for a Book. Include at least two attributes:

ISBN and title, a constructor and a destructor. Create Book.h and Book.cpp.

Declare an array to store 5 string values. Use a loop to enter the values one at a time. Use a separate loop to display the strings on the same line separated by a tab

In your own words, define a function and code an example of creating a function and calling it
Following code inputs a letter and outputs the corresponding International Civil Aviation Organization (ICAO) alphabet word
#include <iostream>
using namespace std;
//function to print code
void printCode(char ch){

Write a code snippet that includes a loop to input 12 positive integers and display the highest value entered without using arrays. The values will be doubles. You must validate that the input values are positive,

Mention at least four mistakes that are easy to make when you are first learning to use selection statements.
End selection statement before opening braces(Adding unwanted semicolon)
Putting wrong operation to test conditions. Like using & instead of && to test and condition
Forgetting to use proper case
Using = instead of ==

(TCO 3) What is the output of the following program?
#include <iostream>
using namespace std;
int main()
{
int x1, x2, i, j, k, y, z;
double f;
x1 = 4;
x2 = 2;
y = 5 + x1--;
z = 5 + ++x2;
i = 6 % 4;
j = 1;
j += j + 3;
k = 25 / 2;
f = (double)((2 / 5) * k);
cout<<"x1 is "<<x1<<"\nx2 is "<<x2<<"\ni is "
<<i<<"\nj is "<<j<<"\nk is "<<k<<"\nk is "
<<k<<"\ny is "<<y<<"\nz is "<<z<<"\nf is "<<f<<endl;
return 0;
}