Computer Science I Final

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

These are operators that add and subtract one from their operands

++ and --

What will the following code display? int x=0;while(x<5) {cout<<x<<endl; x++;}

0 1 2 3 4

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?

1 6 3

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

19

How many times will the following loop display "Hello"? for(int i =20;i>0;i--)

20

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

20

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

21

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

3

What will the following 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 will the following code display? int number=6;int x=0;x=number--;cout<<x<<endl;

5

What will the following code display? int number=6;cout<<number++<<endl;

6

What will the following code display? int number=6;++number;cout<<number<<endl;

7

What will the following code display? int number=6;cout<<++number<<endl;

7

What will the following code display? int number=6;number++;cout<<number<<endl;

7

Which operator is used first: while(x++<10)

<

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

EXIT_FAILURE and ___________ are named constants that may be used to indicate success or failure when the exit() function is called

EXIT_SUCCESS

True or False; A local variable and a global variable may not have the same name within the same program.

False

True or False; Local variables are initialized to zero by default

False

True or False; You must furnish an argument with a function call

False

True or false; A function's return data type must be the same as the function's parameters

False

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

False

True or false; When a function is called, flow of control moves to the function's prototypes

False

True or False; A parameter is a special-purpose variable that is declared inside the parentheses of a function definition

True

True or False; A static variable that is defined within a function is initialized only once, the first time the function is called

True

True or False; Global variables are initialized to zero by default

True

True or false; A while loop's body can contain multiple statements, as long as they are enclosed in braces

True

True or false; It is not considered good programming practice to declare all of your variables globally

True

True or false; It is possible for a function to have some parameters with default arguments and some without

True

True or false; One reason for using functions is to break programs into manageable units, or modules

True

True or 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

A loop that is inside another loop is called:

a nested loop

The while loop has two important parts: an expression that is tested for a true and false value, and:

a statement or block that is repeated as long as the expression is true

A(n)_______________ is information that is passed to a function, and a(n)_____________ is information that is received by a function

argument, parameter

Unlike regular variables, these can hold multiple values

arrays

The statements in the body of a while loop may never be executed, whereas the statements in the body of a do-while loop will be executed:

at least once

This statement causes a loop to terminate early

break

A file____________ is a small holding section of memory that file-bound information is written to

buffer

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

Assuming dataFile is a file stream object, the statement dataFile.close();

closes a file

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

computeValue(10);

This statement may be used to stop a loop's current iteration and begin the next one

continue

This statement may be used to stop a loop's current iteration and begin the next one.

continue

This is a variable that is regularly incremented or decremented each time a loop iterates

counter

In a function header, you must furnish:

data types of the parameters, names of parameter variables, data type of the return value, and the name of the function

A(n) ____________ argument is passed to a parameter when the actual argument is left out of the function call

default

These types of arguments are passed to parameters automatically if no argument is provided in the function call.

default

A function ________________ contains the statements that make up the function

definition

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

document

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

double

The individual values contained in arrays are known as:

elements

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

exit()

If you want a user to enter exactly 20 values, which loop would be the best to use?

for

This loop is a good choice when you know how many times you want the loop to iterate in advance of entering the loop

for

To allow file access in a program, you must #include this header file

fstream

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

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

header

To read data from a file, you define an object of this data type

ifstream

The statement int grades[]={100,90,99,80}; shows an example of

implicit array sizing

This means to increase a value by one

increment

Something within a while loop must eventually cause the condition to become false, or a(n) ______________ loop results

infinite loop

In a for statement, this expression is executed only once

initialization

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

int

Which of the following is a valid C++ array definition?

int array[10];

The while loop contains an expression that is tested for a true or false value, and a statement or block that is repeated as long as the expression:

is true

This type of variable is defined inside a function and is not accessible outside the function

local

This is a control structure that causes a statement or group of statements to repeat

loop

The name of an array stores the ___________ of the first array element

memory address

If you place a semicolon after the test expression in a while loop, it is assumed to be a

null statement

To write data to a file, you define an object of this data type

ofstream

A function can have zero to many parameters, and it can return this many values

only one

A file must be__________ before data can be written to or read from it

opened

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;

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

persist

The do-while loop is a __________ loop that is ideal in situations where you always want the loop to iterate at least once

post-test

The do-while loop is considered a(n) _____________ loop

post-test

The while loop is this type of loop

pre-test

When the increment operator precedes its operand, as in ++num1, the expression is in this mode

prefix

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

prefix increment

A function ____________ eliminates the need to place a function definition before all calls to the function

prototype

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

reference

This statement causes a function to end

return

A two-dimensional array can be viewed as _________ and __________

rows, columns

This is a special value that marks the end of a list of values

sentinel

A two-dimensional array is like __________ put together

several identical arrays

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

static

The value in a(n)_______ variable persists between function calls

static local

This may be used to write information to a file

stream insertion operator

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

stub

By using the same__________ you can build relationships between data stored in two or more arrays

subscript

To access an array element, use the array name and the element's:

subscript

A for statement contains three expressions: initialization, test, and:

update

You may define a ____________ in the initialization expression of a for loop

variable

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

while

If you leave out the size declarator in an array definition:

you must furnish an initialization list


संबंधित स्टडी सेट्स

Hey, King: Get Off Our Backs! Cause/Effect

View Set

EE201 Notes - Russian Domain (Quiz 2)

View Set

Chapter 2 Computer Hardware - SAM study center

View Set

Chapter 8: Managing Human Resources

View Set

Case studies as a research method

View Set

UWorld Adult Health: Musculoskeletal

View Set