CSCI 193 - Final Exam

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

A _____ function contains the statements that make up the function.

Definition

A function contains the statements that make up the function.

Definition

A local variable and a global variable may not have the same name within the same program.

False

True/False: Local variables are initialized to zero by default.

False

True/False: You must furnish an argument with a function call.

False

During which stage does the central processing unit retrieve from main memory the next instruction in the sequence of program instructions?

Fetch

Given the following function definition: void calc (int a, int& b) { int c; c = a + 2; a = a * 3; b = c + a; } What is the output of the following code fragment that invokes calc? int x = 1; int y = 2; int z = 3; calc(x, y); cout << x << " "<< y << " " << z << endl;

1 6 3

Look at the following function prototype. int myFunction (double, double, double); How many parameter variables does this function have?

3

Which of the following statements about global variables is true?

A global variable can have the same name as a variable that is declared locally within a function.

#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; }

2 0 2

How many times will the following loop display "Hello"? for (int i = 0; i <= 20; i++) cout << "Hello!" << endl;

20

This operator always follows the cout object.

<<

This operator always follows the cin object.

>>

What is the while loop?

A pre-test type of loop.

What is the value of cookies after the execution of the following statements? int number = 38, children = 4, cookies; cookies = number % children; A. 2 B. 0 C. 9 D. 0.5 E. None of these

E.

The increment and decrement operators can be used in mathematical expressions; however, they cannot be used in relational expressions.

False

_______ must be included in any program that uses the cout object.

The header file iostream

A(n) ________ is information that is passed to a function, and a(n) ________ is information that is received by a function.

argument, parameter

Functions are ideal for use in menu-driven programs. When a user selects a menu item, the program can ________ the appropriate function.

call

A function is executed when it is:

called

cmath

declares a set of functions to compute mathematical operations

A ________ argument is passed to a parameter when the actual argument is left out of the function call.

default

A function ________ contains the statements that make up the function.

definition

This function causes a program to terminate, regardless of which function or control mechanism is executing.

exit()

This is a collection of statements that performs a specific task.

function

This is a statement that causes a function to execute.

function call

A ________ variable is declared outside all functions.

global

Look at the following function prototype. int myFunction (double); What is the data type of the function's return value?

int

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.

persists

The do while loop is this type of loop.

posttest

When used as parameters, these types of variables allow a function to access the parameter's original argument.

reference

The value in this type of local variable persists between function calls.

static

What does CPU (Central Processing Unit) do?

To fetch instructions, carry out the operations commanded by the instructions, and produce some outcome or resultant information.

iostream

To use cin and cout, the program must include the header file ________.

A CPU really only understands instructions that are written in machine language.

True

A static variable that is defined within a function is initialized only once, the first time the function is called.

True

True/False: A static variable that is defined within a function is initialized only once, the first time the function is called.

True

True/False: It is not considered good programming practice to declare all of your variables globally.

True

True/False: One reason for using functions is to break programs into manageable units, or modules.

True

True/False: The term "bit" stands for binary digit

True

True/False: You may use the exit() function to terminate a program, regardless of which control mechanism is executing.

True

________ functions may have the same name, as long as their parameter lists are different.

Two or more

Look at the following function prototype. int myFunction (double); What is the data type of the function's parameter variable?

double

iomanip

Defines manipulator functions

The cin << statement will stop reading input when it encounters a newline character.

False

fstream header file

Inserts file into the program

ofstream

Output file stream. You create an object of this data type when you want to create a file and write data to it.

The operator increments the value of its operand, then uses the value in context.

Prefix increment

It is a good programming practice to ________ your functions by writing comments that describe what they do.

document

If a function does not have a prototype, default arguments may be specified in the function ________.

header

Which line in the following program contains a call to the showDub function? 1 #include <iostream> 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 }

line 10

Character constants in C++ are always enclosed in ______

single quotes

This is a dummy function that is called instead of the actual function it represents.

stub


Kaugnay na mga set ng pag-aaral

Funds 2 Ch.28: Leading, Managing, and Delegating

View Set

PSYC 2301: Social Psychology (Final Exam)

View Set

NSCI 2114 - Exam Five (Pre-Quiz)

View Set

PrepU Skin Integrity and Wound Care

View Set

Anatomy practical: The anatomical snuffbox

View Set