141 terms

C++ How to program

Chapters 1-10, excluding chapter 5 - from self-review questions
The company that popularized personal computing was ________.
The computer that made personal computing legitimate in business and industry was the ________.
Computers process data under the control of sets of instructions called computer _________.
input unit - output unit - memory unit - arithmetic and logic unit - central processing unit - secondary storage unit
The six key logical units of the computer are the ________, ________, ________, _________, _________ and the ________.
machine languages - assembly languages - high-level languages
,The three classes of languages discussed in the chapter are ________, ________, and ________.
The programs that translate high-level language programs into machine language are called ________.
C is widely known as the development language of the ________ operating system.
The ________ language was developed by Wirth for teaching structured programming.
The Department of Defense developed the Ada language with a capability called ________, which allows programmers to specify that many activities can proceed in parallel.
C++ programs are normally typed into a computer using a(n) ________ program.
In a C++ system, a(n) ________ program executes before the compiler's translation phase begins.
The ________ program combines the output of the compiler with various library functions to produce an executable image.
The ________ program transfers the executable image of a C++ program from disk to memory.
information hiding
Objects have the property of ________although objects may know how to communicate with one another across well-defined interfaces, they normally are not allowed to know how other objects are implemented.
C++ programmers concentrate on creating ________, which contain data members and the member functions that manipulate those data members and provide services to clients.
Classes can have relationships with other classes. These relationships are called ________.
object-oriented analysis and design (OOAD)
The process of analyzing and designing a system from an object-oriented point of view is called ________.
OOD also takes advantage of ________ relationships, where new classes of objects are derived by absorbing characteristics of existing classes, then adding unique characteristics of their own.
Unified Modeling Language(UML)
________ is a graphical language that allows people who design software systems to use an industry-standard notation to represent them.
The size, shape, color and weight of an object are considered
Why might you want to write a program in a machine-independent language instead of amachine-dependent language? Why might a machine-dependent language be more appropriate forwriting certain types of programs?
Machine independent languages are useful for writing programs to be executed on multiple computer platforms. Machine dependent languages are appropriate forwriting programs to be executed on a single platform.
input unit
Which logical unit of the computer receives information from outside the computer foruse by the computer?
computer programming
The process of instructing the computer to solve specific problems is called
assembly language
What type of computer language uses English-like abbreviations for machine language instructions?
output unit
Which logical unit of the computer sends information that has already been processed by the computer to various devices so that the information may be used outside the computer?
memory unit and secondary storage unit
Which logical units of the computer retain information?
arithmetic and logical unit
Which logical unit of the computer performs calculations?
arithmetic and logical unit
Which logical unit of the computer makes logical decisions?
high-level language
The level of computer language most convenient to the programmer for writing programs quickly and easily is
machine language
The only language that a computer directly understands is called that computer's
central processing unit
Which logical unit of the computer coordinates the activities of all the other logical units?
Machine languages are generally
machine dependent
This refers to the standard input device. The standard input device is normally connected to the keyboard
This refers to the standard output device. The standard output device is normally connected to the computer screen.
This refers to the standard error device. Error messages are normally sent to this device which is typically connected to the computer screen.
Why is so much attention today focused on object-oriented programming?
Object-oriented programming enables the programmer to build reusable software components that model items in the real world. Building software quickly, correctly,and economically has been an elusive goal in the software industry. The modular, ob-ject-oriented design and implementation approach has been found to increase pro-ductivity while reducing development time, errors, and cost.
Developed by IBM for scientific and engineering applications
Developed specifically for business applications.
Developed for teaching structured programming
Named after the world's first computer programmer
Developed to familiarize novices with programming techniques
Specifically developed to help programmers migrate to .NET.
Known as the development language of UNIX
Formed primarily by adding object-oriented programming to C
Succeeded initially because of its ability to create web pages with dynamic content
Every C++ program begins execution at the function _________.
{ }
The _________ begins the body of every function and the _________ ends the body of every function.
Every C++ statement ends with a(n) _________.
new line
The escape sequence \n represents the _________ character, which causes the cursor to position to the beginning of the next line on the screen.
Comments do not cause the computer to print the text after the____ on the screen when the program is executed.
The escape sequence ___, when output with cout and the stream insertion operator, causes the cursor to position to the beginning of the next line on the screen.
All ______ must be declared before they are used.
case sensitive
All C++ Variables are_________.
integer operands
The modulus operator (%) can be used only with __________.
int c, thisIsAVariable, q76354, number;
Declare the variables c, thisIsAVariable, q76354 and number to be of type int.
std::cout << "Enter an integer: ";
Prompt the user to enter an integer. End your prompting message with a colon (:) followed by a space and leave the cursor positioned after the space.
std::cin >> age;
Read an integer from the user at the keyboard and store the value entered in integer variable age.
if ( number != 7 )
std::cout << "The variable number is not equal to 7\n";
If the variable number is not equal to 7, print "The variable number is not equal to 7".
std::cout << "This is a C++ program\n";
Print the message "This is a C++ program" on one line.
std::cout << "This is a C++\nprogram\n";
Print the message "This is a C++ program" on two lines. End the first line with C++.
std::cout << "This\nis\na\nC++\nprogram\n";
Print the message "This is a C++ program" with each word on a separate line.
std::cout << "This\tis\ta\tC++\tprogram\n";
Print the message "This is a C++ program" with each word separated from the next by a tab.
// Calculate the product of three integers
Comment that a program calculates the product of three integers.
int x;
int y;
int z;
int result;
Declare the variables x, y, z and result to be of type int (in separate statements).
cout << "Enter three integers: ";
Prompt the user to enter three integers.
cin >> x >> y >> z;
Read three integers from the keyboard and store them in the variables x, y and z.
result = x y z;
Compute the product of the three integers contained in variables x, y and z, and assign the result to the variable result.
cout << "The product is " << result << endl;
Print "The product is " followed by the value of the variable result.
return 0;
Return a value from main indicating that the program terminated successfully.
_____ are used to document a program and improve its readability.
The object used to print information on the screen is _____.
A C++ statement that makes a decision is ______.
Most calculations are normally performed by ______ statements.
valid variable names
_under_bar_, m928134, t5, j7, her_sales, his_account_total, a, b, c, z, z2.
/ %
What arithmetic operations are on the same level of precedence as multiplication? ______.
A house is to a blueprint as a(n) _________ is to a class.
Every class definition contains keyword _________ followed immediately by the class's name.
A class definition is typically stored in a file with the _________ filename extension.
type, name
Each parameter in a function header should specify both a(n) _________ and a(n) _________.
data member
When each object of a class maintains its own copy of an attribute, the variable that represents the attribute is also known as a(n) _________.
access specifier
Keyword public is a(n) _________
Return type _________ indicates that a function will perform a task but will not return any information when it completes its task.
Function _________ from the <string> library reads characters until a newline character is encountered, then copies those characters into the specified string.
binary scope resolution operator (::)
When a member function is defined outside the class definition, the function header must include the class name and the _________, followed by the function name to "tie" the member function to the class definition.
The source-code file and any other files that use a class can include the class's header file via an _________ preprocessor directive.
Sequence, selection and repetition
All programs can be written in terms of three types of control structures:_______, ________and_________.
The_________selection statement is used to execute one action when a condition is TRue or a different action when that condition is false.
What is the difference between a local variable and a data member?
A local variable is declared in the body of a function and can be used only from the point at which it is declared to the immediately following closing brace. A data member is declared in a class definition, but not in the body of any of the class's member functions. Every object (instance) of a class has a separate copy of the class's data members. Also, data members are accessible to all member functions of the class.
Explain the purpose of a function parameter. What is the difference between a parameter and an argument?
A parameter represents additional information that a function requires to perform its task. Each parameter required by a function is specified in the function header. An argument is the value supplied in the function call. When the function is called, the argument value is passed into the function parameter so that the function can perform its task.
Counter-controlled or definite
Repeating a set of instructions a specific number of times is called_________repetition.
Sentinel, signal, flag or dummy
When it is not known in advance how many times a set of statements will be repeated, a(n)_________value can be used to terminate the repetition.
functions, classes
Program components in C++ are called ________ and ________.
function call
A function is invoked with a(n) ________.
local variable
A variable that is known only within the function in which it is defined is called a(n) ________.
The ________ statement in a called function passes the value of an expression back to the calling function.
The keyword ________ is used in a function header to indicate that a function does not return a value or to indicate that a function contains no parameters.
The ________ of an identifier is the portion of the program in which the identifier can be used.
return;, return expression; or encounter the closing right brace of a function.
The three ways to return control from a called function to a caller are ________, ________ and ________.
function prototype
A(n)________ allows the compiler to check the number, types and order of the arguments passed to a function.
Function ________ is used to produce random numbers.
Function ________ is used to set the random number seed to randomize a program.
auto, register, extern, static
The storage-class specifiers are mutable, ________, ________, ________ and ________.
Variables declared in a block or in the parameter list of a function are assumed to be of storage class ________ unless specified otherwise.
Storage-class specifier ________ is a recommendation to the compiler to store a variable in one of the computer's registers.
A variable declared outside any block or function is a(n) ________ variable.
For a local variable in a function to retain its value between calls to the function, it must be declared with the ________ storage-class specifier.
function scope, file scope, block scope, function-prototype scope, class scope, namespace scope
The six possible scopes of an identifier are ________, ________, ________, ________, ________ and ________.
A function that calls itself either directly or indirectly (i.e., through another function) is a(n) ________ function.
A recursive function typically has two components: One that provides a means for the recursion to terminate by testing for a(n) ________ case and one that expresses the problem as a recursive call for a slightly simpler problem than the original call.
In C++, it is possible to have various functions with the same name that operate on different types or numbers of arguments. This is called function ________.
unary scope resolution operator (::)
The ________ enables access to a global variable with the same name as a variable in the current scope.
The ________ qualifier is used to declare read-only variables.
A function ________ enables a single function to be defined to perform a task on many different data types.
This creates a reference parameter of type "reference to double" that enables the function to modify the original variable in the calling function.
Why would a function prototype contain a parameter type declaration such as double &?
Each time you run the program, it will generate the same pattern of numbers.
Why is it often necessary to scale or shift the values produced by rand?
arrays, vectors
Lists and tables of values can be stored in __________ or __________.
name, type
The elements of an array are related by the fact that they have the same ________ and ___________.
subscript (or index)
The number used to refer to a particular element of an array is called its ________.
constant variable
A(n) __________ should be used to declare the size of an array, because it makes the program more scalable.
The process of placing the elements of an array in order is called ________ the array.
The process of determining if an array contains a particular key value is called _________ the array.
An array that uses two subscripts is referred to as a(n) _________ array.
A pointer is a variable that contains as its value the____________ of another variable.
0, NULL, an address
The three values that can be used to initialize a pointer are_____________,__________ and___________.
The only integer that can be assigned directly to a pointer is_____________.
dot (.), arrow (->)
Class members are accessed via the ________ operator in conjunction with the name of an object (or reference to an object) of the class or via the ___________ operator in conjunction with a pointer to an object of the class.
Class members specified as _________ are accessible only to member functions of the class and friends of the class.
Class members specified as _________ are accessible anywhere an object of the class is in scope.
Default memberwise assignment (performed by the assignment operator).
__________ can be used to assign an object of a class to another object of the same class.
To qualify hidden names so that they can be used.
What is the purpose of the scope resolution operator?
member initializers
__________ must be used to initialize constant members of a class.
A nonmember function must be declared as a(n) __________ of a class to have access to that class's private data members.
new, pointer
The __________ operator dynamically allocates memory for an object of a specified type and returns a __________ to that type.
A constant object must be __________; it cannot be modified after it is created.
A(n) __________ data member represents class-wide information.
An object's non-static member functions have access to a "self pointer" to the object called the __________ pointer.
The keyword __________ specifies that an object or variable is not modifiable after it is initialized.
default constructor
If a member initializer is not provided for a member object of a class, the object's __________ is called.
A member function should be declared static if it does not access __________ class members.
Member objects are constructed __________ their enclosing class object.
The __________ operator reclaims memory previously allocated by new.