COSC 1436 Exam 1 Study Guide

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

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

>>, <<

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

Compilers

The ____________ decodes an instruction and generates an electronic signal.

Control Unit

"1user" is a valid C++ identifier.

False

Because C++ is case-sensitive, all programs must have a function called main or Main.

False

If you want to know the length of the string that is stored in a string object, you can call the object's size member function. T/F

False

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

False

What will the following code display? cout << "Roses " << "are red"; cout << "and " << "violets/n" cout << "are" << "blue" << endl;

Roses are redand violets/nareblue

In a C++ program, two slash marks (//) indicate:

the beginning of a comment

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

the data type of the variable

At the heart of a computer is its central processing unit. The CPU's job is:

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

Using C++11: What data type does the compiler determine for the variable cost in the following statement? auto cost = 14.95;

double

the primary activities of a program are:

input, processing, output

____ programs perform a specific task.

application

The ________ is(are) used to display information on the computer's screen.

cout object

to use rand() function, you must include the ________ header file.

cstdlib

If you use a C++ key word as an identifier, our program will:

not compile

In memory, C++ automatically places a(n) __________ at the end of string literals which __________.

null terminator, marks the end of a string

____ are executable statements that inform the user what to do.

prompt lines/prompts

Using C++11: What could be used to initialize an integer variable named dozen with the value of 12?

int dozen {12}; int dozen (12); int dozen = 12; (Cannot put = before numbers that use brackets. Brackets take the place of the = sign)

The numeric data types in C++ can be broke down into two general categories which are:

integers and floating-point numbers

Which statement correctly assigns the character M to the variable names "letter"?

letter = 'M'

A program called a(n) ____ combines the object program with the programs from libraries.

linker

Data items whose values do NOT change while the program is running are called:

literals (This is the name of the data item/value of a constant)

A program that loads an executable program into main memory is called a(n) ____.

loader

Assuming that a program has the following string object definition, which statement correctly assigns the string literal "Jane" to the string object? string name;

name = "Jane" ;

Programs are normally stored in ______________ and loaded into main memory as needed.

secondary storage

you can control the number of significant digits in your output with the ________ manipulator.

setprecision

this manipulator is used to establish a field width for the value that follows it:

setw

Character constants in C++ are always enclosed in ______

single quotation marks ( ' ' )

The float data type is considered _____ precision, and the double data type is considered _______ precision.

single, double

In the following statement, the characters "Hello!" are a(n): cout << "Hello!";

string literal

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

type coercion (could be type conversion too)

You must have a ___________ for every variable you intend to use in a program.

variable definition

what is TRUE about the following statement?cout << setw(4) << num4 << " ";

Allows 4 spaces to print for variable num4

The term that refers to the programmer reading the program from the beginning and stepping through each statement is called:

Desk checking

A preproccessor is a major component of a computer system.

False

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

False

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

False

The fixed manipulator causes a number to be displayed in scientific notation

False

The preproccessor executes after the compiler.

False

What will the following code display? cout << "Four\n" << "score\n"; cout << "and" << "\nseven"; cout << "\nyears" << " ago" << endl;

Four score and seven years ago

A model often used when creating a program that begins with the overall task and refines it into smaller sub tasks is a:

Hierarchy chart

Words that have a special meaning and may be used only for their intended purpose are known as:

Key words

Which line in the following program will cause a compiler error? 1 # include <iostream> 2 using namespace std; 3 4 int main() 5 { 6 const int MY_VAL; 7 MY_VAL = 77; 8 cout << MY_VAL << endl; 9 return 0; 10 }

Line 6

Which line in the following program will cause a compiler error? 1 # include <iostream> 2 using namespace std; 3 4 int main() 5 { 6 const int MY_VAL = 77; 7 MY_VAL = 99; 8 cout << MY_VAL << endl; 9 return 0; 10 }

Line 7

Mistakes that cause a running program to produce incorrect results are called:

Logic errors

What will the following code display? cout << "Monday" ; cout << "Tuesday" ; cout << "Wednesday" ;

MondayTuesdayWednesday

Characters or symbols that perform operations on one or more operands are:

Operators

What must be included in a program that has string variables?

The header file <string>

Suppose that sum is an int variable. The statement sum += 7; is equivalent to the statement sum = sum + 7;

True

The CPU is the most important component in a computer because without it, the computer could not run software:

True

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

True

The maximum number of significant digits in values of the double type is 15.

True

The preproccessor reads a program before it is compiled and only executes those lines beginning with the "#" symbol.

True

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

True

You can use the function getline to read a string containing blanks.

True

Escape sequences are always stored internally as a single character.

True (Example; \n)

Named storage location in the computer's memory that holds a piece of information is a:

Variable

What will be the output after the following lines of code execute? bool choice; choice = true; cout << "Your choice is " << choice << endl;

Your choice is 1

In a cout statement, what will advance the output position to the beginning of the next line?

\n or endl

An Integrated Development Environment typically consists of:

a text editor, a debugger, and a compiler

A set of well-defined steps for performing a task or solving a problem is known as a(n):

algorithm

Which data type typically requires only one byte of storage?

char

The ________ causes the content of another file to be inserted into a program.

#include directive

What is the value of x after the following code executes?int x; x = 3/ static_cast<int>(4.5 + 6.4);

0

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

125.0

The expression static_cast<int>(6.9) + static_cast<int>(7.9) evaluates to ____.

13

What is the value of x after the following code executes? int x = 0; int y = 5; int z = 4; x = x + y + z * 2;

13

The length of the string "computer science" is ____

16

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

2

What is the value of average after the following code executes? double average; average = 1.0 + 2.0 + 3.0 / 3.0;

2.0

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

233445

The value of the expression 33/10, assuming both values are integral data types, is ____.

3 (Converts to integer through

In the following C++ statement, what will be executed first according to the order of precedence? result = 6 - 3 * 2 + 7 - 10 / 2;

3 * 2

What is the value of number after the following statements execute? int number = 10; number += 5; number -= 2; number *= 3;

39

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

4

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

4

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

4 (the decimal and all numbers after are ignored)

What is the value of result after the following statement executes? result = (3 * 5) % 4 + 24 / (15 - (7 - 4) );

5 (15%4, 4 goes into 15 3 times to make 12, remainder of 3 added to 2)

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

9

The first step in writing a program is to

Clearly define what the program should do

Which step uncovers syntax errors in your program?

Compiling

The two methods used by C++ to write computer programs are:

Procedural programming and object-oriented programming

This is used in a program to mark the beginning or ending of a statement, or separate items in a list.

Punctuation

In the process of translating a source file into an executable file, what is the correct sequence?

Source code, preproccessor, modified source code, compiler, object code, linker, executable code.

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

The number is number

What does the term Hardware refer to?

The physical components that a computer is made of.

The purpose of a memory address is:

To identify the location of a byte in memory

A CPU only understands machine language instructions.

True

A named constant is like a variable, but its contents cannot be changed while the program is running.

True

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

True

Floating point constants are normally stored in memory as doubles.

True

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

True

Programming style refers to the way a programmer uses elements such as identifiers, spaces, and blank lines.

True

The data type of a variable whose value can either be true or false is:

bool

The _______ caused a program to wait until information is typed at the keyboard and the Enter key is pressed.

cin object

What will allow the user to enter three values to be stored in variables length, width, height?

cin.get (length, width, height);

For every opening brace in a C++ program, there must be a:

closing brace

A program called a(n) ____ translates instructions written in high-level languages into machine code

compiler

What would define a double-precision floating-point variable named "payCheck"?

double payCheck;

Every complete C++ program must have a _____________.

function named "main"

________ reads a line of input, including leading and embedded spaces, and stores it in a string object.

getline

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

Besides the decimal number system that is most common (base 10), two other number systems that can be used in C++ programs are:

octal and hexidecimal

The ____ monitors the overall activity of the computer and provides services.

operating system

You can use these to override the rules of operator precedence in a mathematical expression.

parentheses

A statement that starts with a hashtag (or pound) symbol (#) is called a:

preproccessor directive


Ensembles d'études connexes

Gould's Pathophysiology - Chapter 14 Neurological Disorders

View Set

Nurs 204 - Chapter 15: Head and Neck (2)

View Set

Chapter 10 DMV: Special Driving Conditions

View Set

Unit 4: Module 19, Persuasion: So Easily Fooled

View Set