EXAM1 (CH 1-2-3)

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

What is the output of the following statements? cout << "123456789012345678901234567890" << endl;cout << setfill('#') << setw(10) << "Mickey"<< setfill(' ') << setw(10) << "Donald" << setfill('*') << setw(10) << "Goofy" << endl;

####Mickey Donald*****Goofy

Suppose that ch1, ch2, and ch3 are variables of the type char and the input is:A BCWhat is the value of ch3 after the following statements execute?cin.get(ch1);cin.get(ch2);cin.get(ch3);

'B'

Suppose that ch1, ch2, and ch3 are variables of the type char and the input is:A BCChoose the value of ch3 after the following statement executes:cin >> ch1 >> ch2 >> ch3;

'C'

Which of the following is a legal identifier?

program_1

____________________ is the process of planning and creating a program.

programming

Main memory is called ____.

random access memory

In a C++ program, ____________________ are used to separate special symbols, reserved words, and identifiers.

white spaces

Suppose that x is an int variable and y is a double variable and the input is:10 20.7Choose the values after the following statement executes: cin >> x >> y;.

x = 10, y = 20.7

Suppose that x is an int variable, y is a double variable and ch is a char variable and the input is:15A 73.2Choose the values after the following statement executes:cin >> x >> ch >> y;

x = 15, ch = 'A', y = 73.2

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

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 12Choose the values of x, y, and z after the following statement executes:cin >> x >> y >> z;

x = 28, y = 32, z = 0.6

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

9

Suppose that x and y are int variables, ch is a char variable, and the input is:4 2 A 12Choose the values of x, y, and ch after the following statement executes:cin >> x >> ch >> y;

This statement results in input failure

Entering a char value into an int variable causes serious errors, called input failure.

True

Main memory is directly connected to the CPU.

True

Suppose a = 5. After the execution of the statement ++a; the value of a is 6.

True

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

True

The basic commands that a computer performs are input (get data), output (display result), storage, and performance of arithmetic and logical operations.

True

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

True

To develop a program to solve a problem, you start by analyzing the problem.

True

Suppose that ch1 and ch2 are char variables and the input is:WXYZWhat is the value of ch2 after the following statements execute?cin.get(ch1);cin.putback(ch1);cin >> ch2;

W

Suppose that ch1 and ch2 are char variables and the input is:WXYZWhat is the value of ch2 after the following statements execute?cin >> ch1;ch2 = cin.peek();cin >> ch2;

X

Which of the following is the newline character?

\n

Suppose that alpha and beta are int variables and alpha = 5 and beta = 10. After the statement alpha *= beta; executes, ____.

alpha = 50

An example of a floating point data type is ____.

double

The ____________________ type is C++ 's method for allowing programmers to create their own simple data types.

enumeration

The memory allocated for a float value is ____ bytes.

four

C++ provides a header file called ____________________, which is used for file I/O.

fstream

The term GB refers to ____.

gigabyte

When you want to process only partial data, you can use the stream function ____ to discard a portion of the input.

ignore

When a value of one data type is automatically changed to another data type, a(n) ____________________ type coercion is said to have occurred.

implicit

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.open("outputData.out");

The function ____________________ returns the next character in the input stream; it does not remove the character from the input stream.

peek

The maximum number of significant digits is called the ____________________.

precision

A _____________ data type is the fundamental or basic data type in C++. It is also called a primitive data type.

predefined

What is the output of the following statements? cout << setfill('*');cout << "12345678901234567890" << endl cout << setw(5) << "18" << setw(7) << "Happy"<< setw(8) << "Sleepy" << endl;

***18**Happy**Sleepy

If a C++ arithmetic expression has no parentheses, operators are evaluated from left to right.

True

The number of input data extracted by cin and >> depends on the number of variables appearing in the cin statement.

True

When reading data into a char variable, after skipping any leading whitespace characters, the extraction operator >> finds and stores only the next character; reading stops after a single character.

True

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

True

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

syntax

Main memory is an ordered sequence of items, called ____.

memory cells

The ASCII data set consists of ____________________ characters.

128

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

13

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

1565.683 85.7800 123.98

The length of the string "computer science" is ____.

16

Suppose that count is an int variable and count = 1. After the statement count++; executes, the value of count is ____.

2

Suppose that x = 25.67, y = 356.876, and z = 7623.9674. What is the output of the following statements?cout << fixed << showpoint;cout << setprecision(2);cout << x << ' ' << y << ' ' << z << endl;

25.67 356.88 7623.97

The value of the expression 17 % 7 is ____.

3

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

3

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

300

The smallest individual unit of a program written in any language is called a(n) ____________________.

token

____ programs perform a specific task for end users.

Application

The ____ is the brain of the computer and the single most expensive piece of hardware in your personal computer.

CPU

In C++, the mechanism that allows you to combine data and operations on the data into a single unit is called a(n) ____________________.

Class

____________________ can be used to identify the authors of the program, give the date when the program is written or modified, give a brief explanation of the program, and explain the meaning of key statements in a program.

Comments

____________________ signals represent information with a sequence of 0s and 1s.

Digital

____ represent information with a sequence of 0s and 1s.

Digital signals

A comma is also called a statement terminator.

False

A mixed arithmetic expression contains all operands of the same type.

False

An operator that has only one operand is called a unique operator.

False

C++ programs have always been portable from one compiler to another.

False

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

False

In C++, reserved words are the same as predefined identifiers.

False

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

False

The device that stores information permanently (unless the device becomes unusable or you change the information by rewriting it) is called primary storage.

False

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

False

The extraction operator >> skips only all leading blanks when searching for the next data in the input stream.

False

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

Insertion Point 1

Assembly language uses easy-to-remember instructions called ____________________.

Mnemonics

In object-oriented design, the first step in the problem-solving process is to identify the components called ____________________, which form the basis of the solution, and to determine how they interact with one another.

Objects

The ____________________ monitors the overall activity of the computer and provides services such as memory management, input/output activities, and storage management.

Operating System

____________________ functions are those that have already been written and are provided as part of the system.

Predefined

In a C++ program, statements that begin with the symbol # are called ____________________ directives.

Preprocessor

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

Prompt lines

____________________ rules determine the meaning of instructions.

Semantic

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

Sunny Day

The digit 0 or 1 is called a binary digit, or ____.

bit

A sequence of eight bits is called a ____.

byte

Suppose that ch1 and ch2 are char variables, alpha is an int variable, and the input is:A 18What are the values after the following statement executes?cin.get(ch1);cin.get(ch2);cin >> alpha;

ch1 = 'A', ch2 = ' ', alpha = 18

Which of the following is a reserved word in C++?

char

Suppose that x and y are int variables. Which of the following is a valid input statement?

cin >> x >> y;

C++ has a special name for the data types istream and ostream. They are called ____________________.

classes

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

compiler

In C++, you can use a(n) ____________________ to instruct a program to mark those memory locations in which data is fixed throughout program execution.

constant

Consider the following program segment. ifstream inFile; //Line 1int x, y; //Line 2... //Line 3 inFile >> x >> y; //Line 4 Which of the following statements at Line 3 can be used to open the file progdata.dat and input data from this file into x and y at Line 4?

inFile.open("progdata.dat");

The devices that feed data and programs into computers are called ____ devices.

input

The basic commands that a computer performs are ____, and performance of arithmetic and logical operations.

input, output, storage

The declaration int a, b, c; is equivalent to which of the following?

int a,b,c;

Manipulators without parameters are part of the ____ header file.

iostream

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

loader

Dividing a problem into smaller subproblems is called ____ design.

structured

A(n) ____________________ is a collection of statements within a program, and when it is activated, or executed, it accomplishes something.

subprogram

Suppose that sum and num are int variables and sum = 5 and num = 10. After the statement sum += num executes, ____.

sum = 15

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

The following statements will result in input failure if the input values are not on a separate line. (Assume that x and y are int variables.)cin >> x;cin >> y;

False

When the computer is turned off, everything in secondary memory is lost.

False

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

False

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

algorithm

C++ comes with a wealth of functions, called ____________________ functions, that are written by other programmers.

predefined


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

EC201 chapters 10,11,12,13, EC 201 Quiz 1, EC 201 Quiz 2, EC 201 Quiz 3, EC 201 Quiz 6, EC201 Chapters 6,7,8, and 9

View Set

Interpersonal communication chap 2 test

View Set

Chapter 35: Assessment of Musculoskeletal Function

View Set

1ES Chapitre 5 Le bilan radiatif terrestre

View Set

Nutrition Ch 8 Water and Minerals

View Set