Procedural Programming Ch 1-3

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

If input failure occurs in a C++ program, the program terminates immediately and displays an error message. True False

False

In the statement cin >> x;, x can be a variable or an expression. True False

False

The devices that feed data and programs into computers are called output devices. True False

False

The following statements will result in input failure if the user does not hit enter between each inputted number. (Assume that num1 and num2 are int variables.) cin >> num1; cin >> num2; True False

False

The result of a logical expression cannot be assigned to an int variable, but it can be assigned to a bool variable. True False

False

When you compile your program, the compiler identifies the logic errors and suggests how to correct them. True False

False

Select all of the identifiers that a C++ compiler will recognize as valid (will not produce a compile-time error). Fifty GO! 5mice woooot bob'sID #hardtest number Count LAUNCH_CODE int1 _3BlindMice _

Fifty woooot LAUNCH_CODE int1 _3BlindMice _

Consider the following code. // Insertion Point 1 using namespace std; const double PI = 3.142; int main() { // Insertion Point 2 double radius = 2.0; double area; area = PI * radius * radius; cout << "Area = " << area <<endl; return 0; } // Insertion Point 3 In this code, where does the include statement belong? Insertion Point 1 Insertion Point 2 Insertion Point 3 Anywhere in the program

Insertion Point 1

The ____________________ monitors the overall activity of the computer and provides services such as memory management, input/output activities, and storage management. Central Processing Unit (CPU) Random Access Memory (RAM) Command prompt System application Motherboard Operating system

Operating system

____ are executable statements that inform the user what to do. Variables Prompt lines Named constants Expressions

Prompt lines

Choose the output of the following C++ statement: cout << "Sunny " << '\n' << "Day " << endl; Sunny \nDay Sunny \nDay endl Sunny Day Sunny \n Day

Sunny Day

Suppose that ch1 and ch2 are char variables and suppose the input from the console at runtime is: WXYZ What is the value of ch2 after the following statements execute? cin.get(ch1); cin.putback(ch1); cin >> ch2; W X Y Z

W

Suppose that ch1 and ch2 are char variables and the input is: WXYZ What is the value of ch2 after the following statements execute? cin >> ch1; ch2 = cin.peek(); cin >> ch2; W X Y Z

X

A step-by-step problem-solving process in which a solution is arrived at in a finite amount of time is called a(n) ____. instruction algorithm recipe design analysis linker

algorithm

Suppose that alpha and beta are int variables. The statement alpha = beta--; is equivalent to the statement(s) ____. beta = beta - 1; alpha = beta; alpha -= beta; alpha = beta - 1; alpha = 1 - beta; alpha = beta; beta = beta - 1;

alpha = beta; beta = beta - 1;

When casting a floating-point number to an integer, the value is _________. left unchanged rounded to the nearest whole number truncated to a whole number rounded up to a whole number

truncated to a whole number

Suppose that x is an int variable, y is a double variable, z is an int variable, and the input is: 15 76.3 14 Choose the values after the following statement executes: cin >> x >> y >> z; x = 15, y = 76, z = 14 x = 15, y = 76, z = 0 x = 15, y = 76.3, z = 14 x = 15.0, y = 76.3, z = 14.0

x = 15, y = 76.3, z = 14

Suppose that x and y are int variables, z is a double variable, and the input is: 28 32.6 12 Choose the values of x, y, and z after the following statement executes: cin >> x >> y >> z; x = 28, y = 32, z = 0.6 x = 28, y = 32, z = 12.0 x = 28, y = 12, z = 32.6 x = 28, y = 12, z = 0.6

x = 28, y = 32, z = 0.6

Entering a char value into an int variable using an input stream (e.g., cin) causes serious errors, called input failure. True False

True

In the following code segment, the extraction operator >> will skip any leading whitespace characters and then store only the next character; any input after that is not read. char input; cout << "Enter your first name: "; cin >> input; True False

True

Information stored in main memory must be transferred to some other device or hardware for permanent storage. True False

True

To use the manipulator setprecision, the program must include the header file ____________________. iostream string cmanipulator cprecision cmath iomanip cmanip cout

iomanip

Which of the following is NOT another term for procedural programming. object-oriented programming structured programming top-down design stepwise refinement bottom-up design modular programming

object-oriented programming

The maximum number of significant digits is called the ____________________. sig. threshold token fixed point endian INT_MAX precision longdouble bit architecture floating-point max

precision

Which of the following is a legal identifier in C++? program! program_1 1program program 1

program_1

Main memory is called ____. read only memory random access memory read and write memory random read only memory

random access memory

The value of the expression 17 % 4 is ____. 0 1 2 3 4 5 6 7

1

The value 0 is the same represented the same in decimal (base-10) and binary (base-2). Likewise, the value of 1 is the same in both numbering systems. However, the value of 2 in decimal is represented as ________ in binary . 2 02 03 10 11 12 0101

10

Suppose that ch1, ch2, and ch3 are variables of the type char and the input is: A B CD What is the value of ch3 after the following statements execute? cin.get(ch1); cin.get(ch2); cin.get(ch3); 'A' 'B' 'C' '\n' 'CD'

'B'

Suppose that ch1, ch2, and ch3 are variables of the type char and the input is: A B CD Choose the value of ch3 after the following statement executes: cin >> ch1 >> ch2 >> ch3; 'A' 'B' 'C' '\n' ' ' 'CD'

'C'

____ is a valid char value. -129 '?' 128 129 A

'?'

In C++, the expression 33 / 10 will be evaluated to be the value ____. 3.0 3 3.3 3.33333

3

Suppose that alpha, beta, and gamma are int variables and the input typed by the user is: 100 110 120 200 210 220 300 310 320 What is the value of gamma after the following statements execute? cin >> alpha; cin.ignore(100, '\n'); cin >> beta; cin.ignore(100,'\n'); cin >> gamma; 100 200 300 320

300

____ is a valid int value in C++ 46,259 46259 462.59 -32.00

46259

The digit 0 or 1 is called a binary digit, or ____. blip Unicode bytecode bit byte hexcode

bit

A sequence of eight bits is called a ____. octal binary digit byte double int

byte

Suppose that x is an int variable, ch is a char variable, and the input is: 276. Choose the values after the following statement executes: cin >> ch >> x; ch = '2', x = 276 ch = '2', x = 76 ch = ' ', x = 276 ch = 276, x = '.'

ch = '2', x = 76

Which of the following is a reserved word in C++? char Char CHAR character

char

A program called a(n) ____ translates instructions written in high-level languages into machine code. linker assembler compiler decoder promoter

compiler

A flow line should only be labeled if it comes out of a ___________ symbol. flow connector decision switch merge terminal process

decision

____________________ signals represent information with a sequence of discrete and finite values. bit boolean analog digital binary input

digital

An example of a floating-point data type is ____. pointer double int short floatable char

double

_________ is a keyword (reserved word) in C++? True boolean Double string false

false

The manipulator ____________________ is used to set the output of a value to be a specific number of characters. setprecision setwidth cin.get() iomanip setw fixed " " showpoint setp

setw

Suppose that x = 1565.683, y = 85.78, and z = 123.982. What is the output of the following statements? cout << fixed; cout << setprecision(3) << x << ' '; cout << setprecision(4) << y << ' '; cout << setprecision(2) << z << endl; 1565.683 85.8000 123.98 1565.680 85.8000 123.98 1565.683 85.7800 123.98 1565.683 85.780 123.980

1565.683 85.7800 123.98

Suppose that alpha and beta are int variables and alpha = 5 and beta = 10. After the statement alpha *= beta; executes, alpha equals ____. 0.2 5 10 15 50 100 150

50

Suppose that x = 55.68, y = 476.859, and z = 23.8216. What is the output of the following statements? cout << fixed << showpoint; cout << setprecision(3); cout << x << ' ' << y << ' ' << setprecision(2) << z << endl; 55.680 476.859 23.82 55.690 476.860 23.82 55.680 476.860 23.82 55.680 476.859 23.821

55.680 476.859 23.82

The expression static_cast<int>(9.9) evaluates to ____. 9 10 9.9 9.0

9

Which of the following is used to terminate a statement in C++ ? endl // end of the line ; // semicolon : // colon . // period

; // semicolon

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

True

Suppose that alpha and beta are int variables. The statement alpha = ++beta; is equivalent to the statement(s) ____. beta = beta + 1; alpha = beta; alpha = beta; beta = beta + 1; alpha = alpha + beta; alpha = beta + 1; alpha += beta;

beta = beta + 1; alpha = beta;

Consider the following C++ program. #include <iostream> using namespace std; int main() { cout << "Hello World." return 0; } In the cout statement, the missing semicolon in the code above will be caught by the ____. compiler editor assembler control unit preprocessor

compiler

The only flow-chart symbol allowed to have multiple inputs is ________. junction procedure flow connector diamond terminal switch decision

flow connector

The command-line command cd stands for "change directory". Another term this type of "directory" is _______. digit desktop background address book folder catalog shortcut list index file

folder

Which of the following is a valid command to compile a C++ file named hello.cpp from the CLI (Command Line Interface) ? g++ -Wextra -O output hello.cpp g++ -Wextra -o output hello.cpp g++ -Wextra -o output hello g++ -wextra -o output hello g++ -wextra -o output hello.cpp

g++ -Wextra -o output hello.cpp

The basic commands that a computer performs are ____, and performance of arithmetic and logical operations. input, file, list output, folder, storage input, output, storage storage, directory, log

input, output, storage

Suppose that outFile is an ofstream variable and output is to be stored in the file outputData.out. Which of the following statements opens the file outputData.out and associates outFile to the output file? outFile("outputData.out"); outFile.open("outputData.out"); open(outFile,"outputData.out"); open.outFile("outputData.out");

outFile.open("outputData.out");

The term ____________________ is used to describe a program that has been written in a high-level language (like C++). compiled code machine code application software object program source computer language

source

Which of the following is a correct way to use the keyword static_cast? static_cast<int>(9.9) static_cast<9.9>(int) static_cast(9.9, int) static_cast<int>[9.9] static_cast(int, 9.9) static_cast<9.9>[int]

static_cast<int>(9.9)

The ____ rules of a programming language tell you which statements are legal, or accepted by the programming language. semantic logical syntax grammatical

syntax

Suppose that top is an int variable, end is a double variable and ch is a char variable and the input is: 15A 73.2 Choose the values after the following statement executes: cin >> top >> ch >> end; top = 15, ch = 'A', end = 73.2 top = 15, ch = 'A', end = 73.0 top = 15, ch = 'a', end = 73.0 This statement results in an error because there is no space between 15 and A.

top = 15, ch = 'A', end = 73.2


Kaugnay na mga set ng pag-aaral

Chapter 5: Underwriting and Policy Issue

View Set

Algebra 1 Mc. Graw Hill Common Core, Test 7: Formula Review

View Set

Nutrition in Health: Chapter 13; Obesity, Energy Balance, and Weight Management

View Set

AP Chemistry - ABSOLUTE COMPLETE MIDTERM!!!!!!

View Set

Maternal newborn ati proctored exam

View Set