Programming

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

How many times will the cout statement be executed? for (int counter = 0; counter <= 5; ++counter) { cout << counter << end; }

6

A ________ is a name that represents a literal value and cannot be changed during the program's execution.

Constant

A good programming process is to write the entire program, type it all in, then incrementally remove bugs one at a time.

False

A variable called average should be declared as an integer data type because it will probably hold data that contains decimal places.

False

An infinite loop will automatically stop after 256 seconds.

False

Assembly language is considered a high-level language.

False

In C++, uppercase and lowercase letters are considered the same (case-insensitive.)

False

It is not possible to increment a counter variable by any value other than 1.

False

Since financial institutions frequently outsource their technical support teams, it is not unusual to receive an email from a bank containing spelling and/or grammar errors and requesting your user-ID and password, social security number, and/or date of birth and there is very little risk in replying with your personal information.

False

To calculate the total number of iterations of a nested loop, add the number of iterations of all the loops.

False

Today, CPUs are huge devices made of electrical and mechanical components such as vacuum tubes and switches.

False

Variable names can have spaces in them.

False

You should not write code that modifies the contents of the counter variable in the body of a for loop.

False

char literals are enclosed in double quotation marks.

False

Every C++ program must have a:

Function main

A mouse is an example of:

Input Device

Each repetition of a loop is known as a(n) _______

Iteration

The programmer has made an error. What will the following code actually display? int number = 7; cout << "The number is " << "number" << end;

The number is number

What will the following segment of code output? int x = 5; if (x != 2) cout << "This is true!" << endl; else cout << "This is false!" << endl;

This is True!

A break statement in a loop causes an immediate jump out of the loop.

True

A compound Boolean expression that has two sub-expressions connected with the && operator is true only when both the sub-expressions are true.

True

A decision structure (e.g. an if statement) can be nested inside another decision structure.

True

A switch statement can more clearly represent multi-branch behavior involving a variable being compared to constant values (when compared to an if statement)

True

If you do not seed the random number generator with srand(), or if you use the same seed value every time your run your program, (for example srand(4)) then you will get the same "random" numbers every time.

True

In a nested loop, the inner loop goes through all of its iterations for every single iteration of the outer loop.

True

Machine language is the only language that a CPU understands

True

The newline escape character \n is functionally equivalent to endl.

True

The test expression in a switch statement must have an integer value.

True

Programmer-defined names of memory locations that may hold data are:

Variables

What will be printed by the following code? string name = "Fred"; cout << name.at(3) << endl;

d

The numeric data types in C++ can be broken into two general categories:

integer and floating point

&&, ||, and ! are ______ operators.

logical

The symbols <=, >=, and != are all ________ opeators.

relational

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

single-line comment

How many times will the cout statement be executed? for (int counter = 0; counter < 5; ++counter) { cout << counter << end; }

5

How many times will the cout statement be executed? for (int counter = 1; counter <= 5; ++counter) { cout << counter << end; }

5

In programming terms, a group of characters inside a set of quotation marks is called a:

string literal

Consider the following code snippet: for (int i = 1; i <= 10; ++i) { for (int j = 1; j <= 5; ++j) { cout << "*"; } cout << endl; } How many asterisks will be printed on each line?

5

Consider the following statements x = 5; y = 10; y = x; After these statements are executed, what is the value of x?

5

The ++ operator adds 2 to its operand.

False

You cannot display the contents of the counter loop in the body of the loop.

False

Programming in C++ can only be done from a computer that runs Windows, since Microsoft Visual Studio only runs on Windows and there are no other C++ compilers for computers that run Mac or Linux.

False

What will the following code output if 11 is entered at the keyboard? int number; cin >> number; if (number > 0) cout << "C++"; else cout << "Soccer"; cout << " is "; cout << "fun" << endl;

C++ is fun

The statements written by the programmer are called:

Source Code

This statement allows you to test the value of an integer variable or expression and then use that value to determine which statement or set of statements to execute:

Switch

The ______ operator takes a Boolean expression as its operand and reverses its logical value.

!

Which of the following is a pre-processor directive, and therefore is not a c++ statement?

#include <iostream>

A compound Boolean expression created with the ______ operator is true only if both of its sub-expressions are true.

&&

This operator represents the logical AND.

&&

Consider the following code: x = 5; while (x < 5) { // loop body } How many times will the loop body iterate?

0

What is the output of the following code? #include <iostream> using namespace std; int main() { int g = 0; while (g <= 3) { cout << g; g = g + 1; } return 0; }

0123

Consider the following code: x = 5; do { // loop body } while (x < 5); How many times will the loop body iterate?

1

Consider the following code snippet: for (int i = 1; i <= 10; ++i) { for (int j = 1; j <= 5; ++j) { cout << "*"; } cout << endl; } How many lines of asterisks will be printed?

10

Look at the following program and answer the question that follows it. 1 // This program displays my gross wages. 2 // I worked 40 hours and I make $20.00 per hour. 3 #include <iostream> 4 using namespace std; 5 6 int main() 7 { 8 int hours; 9 double payRate, grossPay; 10 11 hours = 40; 12 payRate = 20.0; 13 grossPay = hours * payRate; 14 cout << "My gross pay is $" << grossPay << endl; 15 return 0; 16 } Which line(s) in this program cause output to be displayed on the screen?

14

Consider the following statements x = 5; y = 10; y = x + y; After these statements are executed, what is the value of y?

15

What will the value of x be after the following statements execute? int x; x = 18 % 4;

2

What is the output of the following statement? cout << 4 + 5 * 10 / 2 << endl;

29

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

3 * 2

A(n) __________ program translates a high-level language program into a separate machine language program.

Compiler

You use the ______ operator to determine whether two strings are equal.

==

The programmer wants to print a random number. What are the possible values that will be printed by the following statement? cout << rand() % 10 + 100;

A random number between 100 and 109

Whereas < is called a relational operator, x < y is called a(n) ________.

Arithmetic operator

If we are told that a number is decimal, what base is it in?

Base 10

If we are told that a number is binary, what base is it in?

Base 2

In a(n) ________ numbering system, all numeric values are written as sequences of 0s and 1s.

Binary

A byte is made up of eight ________.

Bits

A(n) ______ expression has a value of either true or false.

Boolean

When creating a variable name, which "case" do we use?

Camel Case

In C++, you must _______ a variable before you can us it to store data.

Declare

This section of a switch statement is branched to if none of the case values match the test expression:

Default

This type of loops always executes at least once

Do-While

What will the value of x be after the following statements execute? int x; x = 18 / 4;

E

A ________ performs a calculation and gives a value.

Mathamatical expression

Today's CPUs are small chips known as:

Microprocessors

With whom is it ok to share your Penn State Access Account password?

Nobody

The process of dropping a number's fractional part is called ________ .

Numeric Rounding

What does the term hardware refer to?

Physical Components

The do-while loop is a _______ type of loop.

Posttest

The while loop is a _______ type of loop

Pretest

A(n) _________ is a set of instructions that the computer follows to perform a task.

Program

The computers's main memory is commonly known as:

RAM

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

Scope

Even when there is no power to the computer, data can be held in:

Secondary Storage

White is this funny? !false

beucause its actually true

The string modify operators append and push_back both perform the same function except that append can only be used to add a character to the existing string, while push_back can add a string to the existing string.

false

A(n) _______ loop has no way of ending and repeats until the program is interrupted.

infinite

The programmer has made an error in the code below. What will be the output of the following code segment after the user enters 0 at the keyboard? int x = -1; cout << "Enter a 0 or a 1 from the keyboard: "; cin >> x; if (x=1) cout << "true" << endl; else cout << "false" << endl;

true

You can use a ______ to explicitly convert a value from one numeric data type to another, even if the conversion might result in a loss of data.

type cast experssion

You can use a ________ to temporarily convert a value from one numeric data type to another.

type cast expression

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

x *= 2;

A compound Boolean expression created with the ______ operator is true if either of its sub-expressions is true.

||

A compound boolean expression created with the _______ operator is true if either one of its subexpressions is true.

||

A compound Boolean expression that has two sub-expressions connected with the || operator is true only when both the sub-expressions are true.

False

It is a good idea to create accounts with the same user-id and password on every site you visit so that they are easy to remember.

False

Consider the following statements x = 5; y = 10; y = x; After these statements are executed, what is the value of y? A) 0 B) 5 C) 10 D) 15 E) Not enough information given

5

Consider the following code snippet: for (int i = 1; i <= 10; ++i) { for (int j = 1; j <= 5; ++j) { cout << "*"; } cout << endl; } In all, how many asterisks (total) will be printed by the code?

50

What will the following code display? int x = 5; int y = 5; cout << x++ << " " << ++y endl;

6 6

There are two items that you must specify with a variable declaration: the variable's name and its ________ .

Type

Given the following code: string name = "Fred "; Which statement will update the variable name so that it will contain "Fred Flintstone"?

name.append("Flintstone")


Kaugnay na mga set ng pag-aaral

Combo with "Chemical Bonding" and 15 others

View Set

research 1 study guide for final

View Set

NJ Laws, Rules, & Regulations common to ALL lines

View Set

Theory of planned behavior/ Theory of reasoned action

View Set

World History---Mesopotamia and Egypt

View Set

Force and Motion Calculations (S=D/T and F=MA)

View Set