Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Below is my homework that I need help with. Chapters 5 and 6 is where I been loo

ID: 3633769 • Letter: B

Question

Below is my homework that I need help with. Chapters 5 and 6 is where I been looking.


1) What is the output of the following program?
# include
using namespace std;
void doSomething(int&);
int main( )
{
int x = 2;
cout << x << endl;
doSomething(x);
cout << x << endl;
return 0;
}
void doSomething(int& num)
{
num = 0;
cout << num << endl;
}

A)202 B)000 C)200 D)222

2) Which line in the following program contains the prototype for the showDub function?
1 # include
2 using namespace std;
3
4 void showDub(int);
5
6 int main( )
7 {
8 int x = 2;
9
10 showDub(x);
11 cout << x << endl;
12 return 0;
13 }
14
15 void showDub(int num)
16 {
17 cout << (num * 2) << endl;
18 }
A) 10 B) 4 C) 15 D) 6

3) Here is the header for a function named computeValue:
void computeValue(int value)
Which of the following is a valid call to the function?

A) computeValue(10); B) void computeValue(int x);
C) void computeValue(10); D) computeValue(10)

TRUE/FALSE. Write 'T' if the statement is true and 'F' if the statement is false.
4) A static variable that is defined within a function is initialized only once, the first time the function
is called.
5) One reason for using functions is to break programs into manageable units, or modules.
6) Local variables are initialized to zero by default.
7) It is not considered good programming practice to declare all of your variables globally.

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.
8) To allow file access in a program, you must #include this header file.

A) file B) fileaccess C) cfile D) fstream

9) This may be used to write information to a file.

A) pen object B) stream insertion operator C) output object D) cout object
E) None of these


10) 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?

A) number >> outFile; B) outFile << number;
C) write(outFile, number); D) outFile >> number;

11) A function is executed when it is:
A) called
B) prototyped
C) defined
D) declared
E) None of these

12) The value in this type of local variable persists between function calls.
A) internal
B) dynamic
C) static
D) global
E) None of these

13) ________ functions may have the same name, as long as their parameter lists are different. A) Only two
B) Zero
C) Two or more
D) Un-prototyped
E) None of these

14) It is a good programming practice to ________ your functions by writing comments that describe
what they do.
A) eliminate
B) document
C) prototype
D) execute
E) None of these
15) A function ________ eliminates the need to place a function definition before all calls to the
function.

A) parameter
B) header
C) argument
D) prototype
E) None of these
3
16) EXIT_FAILURE and ________ are named constants that may be used to indicate success or failure
when the exit( ) function is called.
A) RETURN_OK
B) EXIT_OK
C) EXIT_SUCCESS
D) EXIT_TERMINATE
E) None of these

17) Look at the following function prototype.
int myFunction(double);
What is the data type of the funtion's parameter variable?
A) int B) void
C) double D) can't tell from the prototype

18) If a function is called more than once in a program, the values stored in the function's local
variables do not ________ between function calls.
A) change
B) persist
C) communicate
D) execute
E) None of these
19) A(n) ________ is information that is passed to a function, and a(n) ________ is information that is
received by a function.

A) prototype, header
B) parameter, argument
C) function call, function header
D) argument, parameter
E) None of these

TRUE/FALSE. Write 'T' if the statement is true and 'F' if the statement is false.
20) The increment and decrement operators can be used in mathematical expressions; however, they
cannot be used in relational expressions.
21) Multiple relational expressions cannot be placed into the test condition of a for loop. 21)
MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.
22) What will the following code display?
int x = 0;
for (int count = 0; count < 3; count++)
x += count;
cout << x << endl;
22)
A) 0 B) 3 C) 6 D)012

23) A file must be ________ before data can be written to or read from it. A) opened
B) buffered
C) closed
D) initialized
E) None of these

24) What will the following code display?
int number = 6
int x = 0;
x = --number;
cout << x << endl;
A) 5 B) 0 C) 7 D) 6

25) What will the following code display?
int number = 6;
cout << number++ << endl;
A) 6 B) 0 C) 7 D) 5

26) What will the following loop display?
int x = 0;
while (x < 5)
{
cout << x << endl;
x++;
}
A)01234
B)012345
C) 01 2 3 4
D) The loop will display numbers starting at 0, for infinity.

27) This is a pre-test loop that is ideal in situations where you do not want the loop to iterate if the
condition is false from the beginning.
A) while
B) do-while
C) for
D) infinite
E) None of these

28) If you want a user to enter exactly 20 values, which loop would be the best to use? 28)
A) for
B) do-while
C) while
D) infinite
E) None of these

29) This is a special value that marks the end of a list of values. 29)
A) variable
B) constant
C) loop
D) sentinel
E) None of these

30) This is a control structure that causes a statement or group of statements to repeat. 30)
A) loop
B) decision statement
C) constant
D) cout object
E) None of these

31) This means to increase a value by one. 31)
A) increment
B) modulus
C) decrement
D) parse
E) None of these

32) A loop that is inside another loop is called: 32)
A) a nested loop
B) an infinite loop
C) a post-test loop
D) a pre-test loop
E) None of these

33) A for statement contains three expressions: initialization, test, and: 33)
A) null
B) validation
C) reversal
D) update
E) None of these

34) When the increment operator precedes its operand, as in ++num1, the expression is in this mode. 34)
A) prefix
B) preliminary
C) binary
D) postfix
E) None of these
35) In a for statement, this expression is executed only once.
A) null
B) initialization
C) validation
D) test
E) None of these

36) This is a dummy function that is called instead of the actual function it represents.
A) overloaded function B) main function
C) stub D) driver

37) A file ________ is a small holding section of memory that file-bound information is first written to.
A) buffer
B) name
C) segment
D) number
E) None of these

TRUE/FALSE. Write 'T' if the statement is true and 'F' if the statement is false.
38) A while loop's body can contain multiple statements, as long as they are enclosed in braces.
MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.
39) The value in a(n) ________ variable persists between function calls.
A) dynamic B) static local C) counter D) local

40) What is the output of the following program?
# include
using namespace std;
void doSomething(int);
int main( )
{
int x = 2;
cout << x << endl;
doSomething(x);
cout << x << endl;
return 0;
}
void doSomething(int num)
{
num = 0;
cout << num << endl;
}
40)
A)200
B)000
C)222
D)202

41) Assuming dataFile is a file stream object, the statement dataFile.close();
A) is illegal in C++
B) closes a file
C) is legal but risks losing valuable data
D) needs a filename argument to execute correctly
E) None of these

42) How many times will the following loop display "Hello"?
for (int i = 0; i <= 20; i++)
cout << "Hello!" << endl;
A) 19 B) 21
C) 20 D) an infinite number of times

TRUE/FALSE. Write 'T' if the statement is true and 'F' if the statement is false.
43) An output file is a file that data is written to.
44) It is possible to define a file stream object and open a file in one statement.

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.
45) This is a collection of statements that performs a specific task.
A) constant
B) variable
C) function
D) infinite loop
E) None of these

46) Which line in the following program contains a call to the showDub function?
1 #include
2 using namespace std;
3
4 void showDub(int);
5
6 int main( )
7 {
8 int x = 2;
9
10 showDub(x);
11 cout << x << endl;
12 return 0;
13 }
14
15 void showDub(int num)
16 {
17 cout << (num * 2) << endl;
18 }

A) 15 B) 6 C) 4 D) 10

47) Look at the following function prototype.
int myFunction(double);
What is the data type of the funtion's return value?
A) void B) double
C) int D) can't tell from the prototype

48) What is the output of the following program?
# include
using namespace std;
int getValue(int);
int main( )
{
int x = 2;
cout << getValue(x) << endl;
return 0;
}
int getValue(int num)
{
return num + 5;
}

A) 5 B) 7 C) 2 D) "getValue(x)"

TRUE/FALSE. Write 'T' if the statement is true and 'F' if the statement is false.
49) It is possible for a function to have some parameters with default arguments and some without.
50) You must furnish an argument with a function call.

Explanation / Answer

please rate - thanks

this is too much for 1 post

I'll do some


1) What is the output of the following program?
# include <iostream>
using namespace std;
void doSomething(int&);
int main( )
{
int x = 2;
cout << x << endl;
doSomething(x);
cout << x << endl;
return 0;
}
void doSomething(int& num)
{
num = 0;
cout << num << endl;
}

A)202 B)000 C)200 D)222    each number will be on it's own line

2) Which line in the following program contains the prototype for the showDub function?
1 # include
2 using namespace std;
3
4 void showDub(int);
5
6 int main( )
7 {
8 int x = 2;
9
10 showDub(x);
11 cout << x << endl;
12 return 0;
13 }
14
15 void showDub(int num)
16 {
17 cout << (num * 2) << endl;
18 }
A) 10 B) 4 C) 15 D) 6

3) Here is the header for a function named computeValue:
void computeValue(int value)
Which of the following is a valid call to the function?

A) computeValue(10); B) void computeValue(int x);
C) void computeValue(10); D) computeValue(10)

TRUE/FALSE. Write 'T' if the statement is true and 'F' if the statement is false.
4) A static variable that is defined within a function is initialized only once, the first time the function
is called.           TRUE
5) One reason for using functions is to break programs into manageable units, or modules.   TRUE
6) Local variables are initialized to zero by default.    FALSE
7) It is not considered good programming practice to declare all of your variables globally.    TRUE

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.
8) To allow file access in a program, you must #include this header file.

A) file B) fileaccess C) cfile D) fstream

9) This may be used to write information to a file.

A) pen object B) stream insertion operator C) output object D) cout object
E) None of these


10) 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?

A) number >> outFile; B) outFile << number;
C) write(outFile, number); D) outFile >> number;

11) A function is executed when it is:
A) called
B) prototyped
C) defined
D) declared
E) None of these

12) The value in this type of local variable persists between function calls.
A) internal
B) dynamic
C) static
D) global
E) None of these

13) ________ functions may have the same name, as long as their parameter lists are different. A) Only two
B) Zero
C) Two or more
D) Un-prototyped
E) None of these

14) It is a good programming practice to ________ your functions by writing comments that describe
what they do.
A) eliminate
B) document
C) prototype
D) execute
E) None of these
15) A function ________ eliminates the need to place a function definition before all calls to the
function.

A) parameter
B) header
C) argument
D) prototype
E) None of these
3
16) EXIT_FAILURE and ________ are named constants that may be used to indicate success or failure
when the exit( ) function is called.
A) RETURN_OK
B) EXIT_OK
C) EXIT_SUCCESS
D) EXIT_TERMINATE
E) None of these

17) Look at the following function prototype.
int myFunction(double);
What is the data type of the funtion's parameter variable?
A) int B) void
C) double D) can't tell from the prototype

18) If a function is called more than once in a program, the values stored in the function's local
variables do not ________ between function calls.
A) change
B) persist
C) communicate
D) execute
E) None of these
19) A(n) ________ is information that is passed to a function, and a(n) ________ is information that is
received by a function.

A) prototype, header
B) parameter, argument
C) function call, function header
D) argument, parameter
E) None of these

TRUE/FALSE. Write 'T' if the statement is true and 'F' if the statement is false.
20) The increment and decrement operators can be used in mathematical expressions; however, they
cannot be used in relational expressions.    FALSE
21) Multiple relational expressions cannot be placed into the test condition of a for loop.   FALSE

21)
MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.
22) What will the following code display?
int x = 0;
for (int count = 0; count < 3; count++)
x += count;
cout << x << endl;
22)
A) 0 B) 3 C) 6 D)012                 B)3

23) A file must be ________ before data can be written to or read from it. A) opened
B) buffered
C) closed
D) initialized                 
E) None of these               A) opened

24) What will the following code display?
int number = 6
int x = 0;
x = --number;
cout << x << endl;
A) 5 B) 0 C) 7 D) 6                 A)5

25) What will the following code display?
int number = 6;
cout << number++ << endl;
A) 6 B) 0 C) 7 D) 5             A) 6

26) What will the following loop display?
int x = 0;
while (x < 5)
{
cout << x << endl;
x++;
}
A)01234
B)012345
C) 01 2 3 4
D) The loop will display numbers starting at 0, for infinity.               A) 01234

27) This is a pre-test loop that is ideal in situations where you do not want the loop to iterate if the
condition is false from the beginning.
A) while                                     
B) do-while
C) for
D) infinite
E) None of these                                A) while

28) If you want a user to enter exactly 20 values, which loop would be the best to use? 28)
A) for
B) do-while
C) while
D) infinite
E) None of these                               A) for

29) This is a special value that marks the end of a list of values. 29)
A) variable
B) constant
C) loop
D) sentinel
E) None of these                                 D) sentinel

30) This is a control structure that causes a statement or group of statements to repeat. 30)
A) loop
B) decision statement
C) constant
D) cout object
E) None of these                              A) loop

31) This means to increase a value by one. 31)
A) increment
B) modulus
C) decrement
D) parse
E) None of these                         A) increment

32) A loop that is inside another loop is called: 32)
A) a nested loop
B) an infinite loop
C) a post-test loop
D) a pre-test loop
E) None of these

33) A for statement contains three expressions: initialization, test, and: 33)
A) null
B) validation
C) reversal
D) update
E) None of these                            D) update

34) When the increment operator precedes its operand, as in ++num1, the expression is in this mode. 34)
A) prefix
B) preliminary
C) binary
D) postfix
E) None of these                                   A) prefix
35) In a for statement, this expression is executed only once.
A) null
B) initialization
C) validation
D) test
E) None of these                           B) initialization

36) This is a dummy function that is called instead of the actual function it represents.
A) overloaded function B) main function
C) stub D) driver                                        c) stub

37) A file ________ is a small holding section of memory that file-bound information is first written to.
A) buffer
B) name
C) segment
D) number
E) None of these                       A) buffer

TRUE/FALSE. Write 'T' if the statement is true and 'F' if the statement is false.
38) A while loop's body can contain multiple statements, as long as they are enclosed in braces.   TRUE
MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.
39) The value in a(n) ________ variable persists between function calls.   
A) dynamic B) static local C) counter D) local              B) Static

40) What is the output of the following program?
# include
using namespace std;
void doSomething(int);
int main( )
{
int x = 2;
cout << x << endl;
doSomething(x);
cout << x << endl;
return 0;
}
void doSomething(int num)
{
num = 0;
cout << num << endl;
}
40)
A)200
B)000
C)222
D)202                                     A)200 this is question 1

41) Assuming dataFile is a file stream object, the statement dataFile.close();
A) is illegal in C++
B) closes a file
C) is legal but risks losing valuable data
D) needs a filename argument to execute correctly
E) None of these                                                                 B) closes a file

42) How many times will the following loop display "Hello"?
for (int i = 0; i <= 20; i++)
cout << "Hello!" << endl;
A) 19 B) 21
C) 20 D) an infinite number of times                  B) 21

TRUE/FALSE. Write 'T' if the statement is true and 'F' if the statement is false.
43) An output file is a file that data is written to.                  TRUE
44) It is possible to define a file stream object and open a file in one statement.             TRUE

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.
45) This is a collection of statements that performs a specific task.
A) constant
B) variable
C) function
D) infinite loop
E) None of these                                   C) function ?

46) Which line in the following program contains a call to the showDub function?
1 #include
2 using namespace std;
3
4 void showDub(int);
5
6 int main( )
7 {
8 int x = 2;
9
10 showDub(x);
11 cout << x << endl;
12 return 0;
13 }
14
15 void showDub(int num)
16 {
17 cout << (num * 2) << endl;
18 }

A) 15 B) 6 C) 4 D) 10                                    C) 4   you asked this before

47) Look at the following function prototype.
int myFunction(double);
What is the data type of the funtion's return value?
A) void B) double
C) int D) can't tell from the prototype                          C) int

48) What is the output of the following program?
# include
using namespace std;
int getValue(int);
int main( )
{
int x = 2;
cout << getValue(x) << endl;
return 0;
}
int getValue(int num)
{
return num + 5;
}

A) 5 B) 7 C) 2 D) "getValue(x)"                 b) 7

TRUE/FALSE. Write 'T' if the statement is true and 'F' if the statement is false.
49) It is possible for a function to have some parameters with default arguments and some without.   TRUE
50) You must furnish an argument with a function call.                  FALSE

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote