COSC 1336 Midterm - Chp 1-6

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

Which statement is equivalent to the following? Number +=1;

Number = Number + 1;

Escape sequences are always stored internally as a single character.

True

Global variables are initialized to zero by default.

True

If the expression on the left side of the following is false, the expression on the right side will not be checked. (a >= b) && (c == d)

True

In C++ 11 you can pass a string object as an argument to a file stream objects open member function.

True

It is possible for a function to have some parameters with default arguments and some without.

True

The update expression of a for loop can contain more than one statement, for example: for (i=5; i <= 10; i++, total+= sales)

True

When C++ is working with an operator, it strives to convert the operands to the same type

True

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

Two or more

A _______ variable is declared outside all functions

global

In C++, key words are written in all lowercase

True

The CPU is the most important component in a computer, without it wont run software.

True

Which value can be entered to cause the following code segment to display the message "That number is acceptable." Int number; Cin >> number; If (number > 10 && number < 100) Cout << " That number is acceptable. \n"; Else Cout << "That number is not acceptable. \n";

99

The _____ operator always follows the cin object and the _____ operator follows the cout object.

>>, <<

a debugging process where you the programmer pretend you are a computer and step through each statement while recording the value of each variable at each step is known as

hand tracing

A computer stores a program while it is running

in main memory

When a user types values on a keyboard, those values are first stored

in the keyboard buffer

This means to increase value

increment

In a for statement, this expression is executed only once

initialization

When a program lets the user know that an invalid choice has been made, this is known as:

input validation

What is the data type of the following function prototypes return value? int myFunction(double);

int

The numeric data types in c++ can be broken into two general categories which are

integers and floating-point numbers

a computer monitor

is a type of output device

When the final value of an expression is assigned to a variable, it will be converted to:

the data type of the variable

which of the following must be included in any program that uses the cin object?

the header file iostream

Arithmetic operators that share the same precedence have right to left associativity.

False

In C++ it is impossible to display the number 34.789 in a field of 9 spaces with 2 decimal places of precision.

False

In programming, the terms "line" and "statement" always mean the same thing.

False

Local variables are initialized to zero by default.

False

Pseudocode is a form of a program statement that will always evaluate to false.

False

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

False

When a program uses the setw manipulator, the iosetwidth header file must be included in a preprocessor directive,

False - the iomanip header must be used

How many characters with the following statement read into the variable myString? cin >> setw(10) >> myString;

9

This is a complete instruction that causes the computer to perform some action.

statement

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

static

When a relational expression is false, it has the value ________.

0

What is the value of donuts int donuts = 10; if (donuts != 10) donuts = 0; else donuts +=2;

12

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

EXIT_SUCCESS

A function's return data type must be the same as the function's parameter(s).

False

The preprocessor executes after the compiler

False

The scope of a variable declared in a for loop's initialization expression always extends beyond the body of the loop.

False

When a function is called, flow of control moves to the functions prototype.

False

In C++ 11, if you want an integer to be treated as a long long int, you can append ____ at the end of the number

LL

Which of the following must be included in a function header?

The data type of each parameter The data type of the return value The name of the function The names of the parameter variables

Which of the following will allow the user to input the values 15 and 20 and have them stored in variables named base and height, respectively?

cin >> base >> height

The _________ causes a program to wait until info is typed at the keyboard and the Enter key is pressed.

cin object

Which of the following functions tells the cin object to skip one or more characters in the keyboard buffer?

cin.ignore

The first step in writing a program is to

clearly define what the program is to do

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

closes a file

Relational operators allow you to ________ numbers.

compare

Which step uncovers any syntax errors in your program

compiling

What is the data type of the following function prototypes parameter variable? int myFunction(double)

double

Which of the following defines a double-precision floating-point variable named payCheck?

double payCheck;

The data type used to declare variables that can hold real numbers is

float

every complete c++ program must have a

function named main

________ are used to translate each source code instruction into the appropriate machine language instruction.

Compilers

A parameter is a special-purpose variable that is declared inside the parentheses of a function definition.

True

A set of well-defined steps for performing a task or solving a problem is known as an

algorithm

Given that x = 2, y = 1, and z = 0, what will the following cout statement display? cout << "answer = " << (x || !y && z) << endl;

answer = 1

A ______ is information that is passed to a function, and a _______ is information received by that function.

arguement, parameter

A statement that causes a loop to terminate early is

break

During which stage does the central processing unit analyze the instruction and encode it in the form of a number, and then generate an electronic signal?

decode

The _________ loop is ideal in situations where you want the loop to iterate at least once.

do-while

The purpose of a memory address is:

to identify the location of a byte in a memory.

A volatile type of memory that is used for temporary storage is

RAM

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 (Line 7 on the test)

Which of the following statements correctly assigns the character M to the variable named letter?

'M'

what will the following code display? int x = 23, y = 34, z=45; cout << x << y << z << endl;

233445

In the following function prototype, how many parameter variables does this function have? int myFunction(double, double, double);

3

Given the if/else statement if (a <5) b = 12; else d = 30

a < 5 ? b = 12 : d = 30;

Which line in the following program contains the header for 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 15 (Line 11 on the test)

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

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

#include fstream

This operator represents the logical AND.

&&

what will be displayed after the following statements execute> int funny = 7, serious = 15; funny = serious % 2; if (funny != 1) { funny = 0; serious = -; } else if (funny == 2) { funny = 10; serious = 10; } else { funny = 1; serious = 1; } cout << funny << " " << serious ,, endl;

1 1

What is the value of cube after the following code executes? double cube, side; side = 5.0; cube = pow(side, 3.0);

125.0 5*5*5

After the following code executes, what is the value of my_value if the user enters 0? cin >> my_value; if (my_value > 5) my_value = my_value + 5; else if (my_value > 2) my_value = my_value + 10; else my_value = my_value + 15;

15

What is the value of cookies after the following statements execute? int number = 38, children = 4, cookies; cookies = number % children;

2

What will display? #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 0

What will the following loop display? int x = 0; for (int count = 0; count < 3; count++) x += count; cout << x << endl;

3

What is the value of a number after the following statements execute? int number; number = 18 % 4 + 2

4 - Division or modulus goes first, then addition

What is the value of number after the following statements execute? int number; number = 18 / 4;

4 - Without the modulus, there is no remainder.

int number = 6; int x = 0; x= number--; cout << x << endl;

6

int number = 6; ++number; cout << number << endl;

7

input values

All of these: An Appropriate Range Reasonableness Division by zero, if division in taking place

At the heart of the computer, is its central processing unit. The CPUs job is:

All of these: to fetch instructions to carry out the operations commanded by the instructions to produce some outcome or resultant information

You may not use both break and continue statements within the same set of nested loops.

False

What is the output of the following code statement int number; cout << "Enter a number: "; cin >> number; if (number > 0) cout << "Hi, there!" << endl; else cout << "Good-bye." << endl;

Hi, there!

WHich line will cause a compiler error #include <iostream> using namespace std; int main() { const int X = 77; X = 99; cout << X << endl; return 0; }

Line 7 X = 99 - It was already defined on line 6

What will the following code display? int number = 23; cout << "The number is " << "number" << endl;

The number is number

What does the term hardware refer to?

The physical components that make up a computer.

What is the output of the following code segment? int x = 5; if (x=2) cout << "This is true!" << endl; else cout <<"This is false!" << endl; cout << "That's all, folks!" << endl;

This is true! That's all folks!

An expression that has any value other than 0 is considered true by an if statement.

True

An initialization expression may be omitted from the for loop if no initialization is required.

True

As a rule of style, when writing an if statement you should indent the conditionally- executed statements.

True

Both of the following if statements perform the same operation. if (sales > 10000) commissionRate = 0.15; if (sales > 10000) commissionRate = 0.15;

True

C++ does not have a built in data type for storing strings of data.

True

When typing in your source code into the computer, you must be very careful since most of your C++ instructions, header files, and variable names are case sensitive.

True

A do-while loop is considered

a post-test loop

the two important parts of a while loop are the expression that is tested for a true or false value and

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

The programmer usually enters source code into a computer with

a text editor

Which of the following statements will read an entire line of input into the string object, address?

getline(cin, address)

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

infinite loop

This manipulator causes the field to be left-justified with padding spaces printed to the right.

left

These operators connect two or more relational expressions into one, or reverse the logic of an expression.

logical

A loop that is inside another loop is called:

nested loop

Which statement is equivalent to the following? number = number * 2;

number *=2;

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;

A _______ is a set of instructions that the computer follows to solve a problem.

program

Given the following code segment, what is the output? int x = 1, y = 1, z = 1; y = y+z; x = x+y; cout << "result = " << (x < y ? y : x) << endl;

result = 3

A variable's _______ is the part of the program that has access to the variable.

scope

You can control the number of significant digits in your output with the __________ manipulator

setprecision

In the following statement, the characters Hello! are a cout << "Hello!";

string literal

The two parts of the CPU are

the Control Unit and the Arithmetic and Logic Unit

In a C++ program, two slash marks // indicate

the beginning of a comment

Which of the following is not one of the major components of a computer system?

the preprocessor

The default section of a switch statement performs a similar task as the ________ portion of an if/else if statement.

trailing else

A ______ represents a storage location in the computers memory.

variable


Kaugnay na mga set ng pag-aaral

Condensed BUS Law Exam Review #1

View Set

Bias in the Media; Modes of Persuasion

View Set

Marketing Management M4 (Ch. 14) Quiz Review

View Set

Legal Environment Business Exam 5 (chapter 24)

View Set

BUS/475: Integrated Business Topics Wk 4 - Practice: Ch . 8, Corporate Strategy: Vertical [due Day 5]

View Set

Chapter 48: Nursing Care of the Child With an Alteration in Metabolism/Endocrine Disorder

View Set