Shared Flashcard Set

Details

C++ exam 1
exam 1
62
Computer Science
Undergraduate 4
10/02/2016

Additional Computer Science Flashcards

 


 

Cards

Term
The ____ is the part of a function definition that shows the function name, return type, and parameter list.
Definition
Header
Term
If function showValue has the following header: void showValue(int quantity) you would use the statement ______ to call it with the argument 5.
Definition
showValue(5)
Term
Values that are sent into a function are called _____.
Definition
arguments
Term
When only a copy of an argument is passed to a function, it is said to be passed by _____.
Definition
Value
Term
A(n) ______ variable is defined inside a function and is not accessible outside the function.
Definition
Local
Term
If a function has a local variable with the same name as a global variable, only the _____ variable can be seen by the function.
Definition
local
Term
The _____ statement causes a function to end immediately.
Definition
return
Term
When a function uses a mix of parameters with and without default arguments, the parameters with default arguments must be defined _______.
Definition
last
Term
When used as parameters, _______ variables allow a function to acccess the parameters original argument.
Definition
reference
Term
Reference variables allow arguments to be passed by _______.
Definition
reference
Term
What is the difference between an argument and a parameter variable?
Definition
An argument is in the function call (in parantheses) and represent the actual values passed into a function. Parameters are in the function header and receive the arguments.
Term
The following statement calls a function named half, which returns a value that is half that of the argument passed to it. assume that result and number have both been defined to be double variables. Write the half function. result = half(number); .
Definition

double half (double value){

return value / 2;

}

Term
Internally, the CPU consists of the _____ and the ______.
Definition
ALU and control unit
Term
The two categories of software are ______ and _____.
Definition
Operating systems and application software.
Term
Since computers can't be programmed in natural human language, algorithms must be written in a(n) ______ language.
Definition
programming language
Term
A program's ability to run on several different types of computer systems is called ______.
Definition
portability
Term
Words or names defined by the programmer are called ____________.
Definition
programmer defined symbols.
Term
The three primary activities of a program are __, ___ and ___.
Definition
Input, processing, output.
Term
Every complete statement ends with a ____.
Definition
semicolon
Term

Assume a string object has been defined as follows:

string description;

A) write a cin statement that reads in a one word description. 

B) write a statement that reads in a description that can contain multiple words separated by blanks. 

 

Definition

A) cin >> description;

B) getline(cin, description);

Term

What header files must be included in the following program?

int main() {

    double amount = 89.7;

    cout << fixed << showpoint << setprecision(1);

    cout << setw(8) << amount << endl;

    return 0;

}

Definition
iostream and iomanip
Term
Write a definition statement for a C-string object that can hold a string 30 characters in length.
Definition

string city;

// no size declaration is needed

Term
Write a cout statement that uses stream manipulators to display the contents of the variable divSales in a field of eight spaces, in a fixed-point notation, with a decimal point and two decimal digits.
Definition

cout << fixed << showpoint << setprecision(2);

cout << setw(8) << divSales << endl;

Term
An expression using the greater-than, less-than, greater-than-or-equal-to, etc... is called a(n) ______ operator.
Definition
relational
Term
The if statement regards an expression with the value 0 as ____ and an expression with a nonzero value as ____.
Definition
false, true
Term
The ____ logical operator works best when testing a number to determine if it is within a range.
Definition
&&
Term

Convert the following conditional expression into an if/else statement. 

q = (x < y) ? (a + b) : (x * 2);

Definition

if (x < y){

    q = a + b;

else {

    q = x * 2;

}

 

Term
The following statement should determind if x is not greater than 20. What is wrong with it? if (!x > 20)
Definition
if (!(x >20))
Term
When the increment or decrement operator is placed after the operand (or to the operand's right), the operator is being used in _____ mode.
Definition
prefix
Term
The statement or block that is repeated is known as the ____ of the loop.
Definition
body
Term
A(n) ____ is a sum of numbers that accumulates with each iteration of a loop.
Definition
running total
Term
A(n) ______ is a special value that marks the end of a series of values.
Definition
sentinel
Term
Inside the for loop's parentheses, the first expression is the _____, the second is the ____ , and the thrid expression is the _____ .
Definition
initialization, test, update.
Term
The ____ statement causes a loop to terminate immidiately.
Definition
break
Term
What header file do you need to include in a program that performs file operations?
Definition
fstream
Term
What is a file's read position? Where is the read position when a file is first opened for reading?
Definition
A read position marks the location of the next byte to read. When an input file is opened, the default is the first byte of the file.
Term

Convert the following while loop to a for loop: 

int count = 0 ;

while (count < 50){

    cout << "count is " << count << endl;

    count++;

}

Definition

for (int count = 0; count < 50; count++){

    cout << "count is " << count << endl;

}

Term

Complete the program segment below to write the numbers 1 through 50 to the numbers.txt file. 

ofstream outputFile;

outputFile.open("numbers.txt");

 

//you write this code

 

outputFile.close();

Definition

for (int num = 1; num <=50; num++)

outfile << num << " ";

Term
The ____ is the part of a funciton definition that shows the funcction name, return type, and parameter list.
Definition
header
Term
Values that are sent into a function are called ____.
Definition
arguments
Term
When only a copy of an argument is passed to a function, it is said to be passed by _____.
Definition
value
Term
What does ADT stand for?
Definition
Abstract data type
Term
Creating a class object is often called _____ the class.
Definition
Instantiating
Term
An object's data items are stored in its _____.
Definition
member variables
Term
Bundling together an object's data and procedures is called _______.
Definition
encapsulation
Term
Normally a class's ____ are declared to be private and ________ public.
Definition
member variables, member functions
Term
A class member function that changes the value of a member variable is called a(n) ____.
Definition
mutator
Term
constructors cannot have a(n) ______ type.
Definition
return
Term
A destructor is a member function that is automatically called when an object is ______.
Definition
destroyed
Term
A constructor with all default values is a(n) ______ constructor
Definition
default
Term
A class may only have one default ____ and one ____.
Definition
constructor, destructor
Term
When a member function forms part of the interface through which a client program can use the class, the function must be _____.
Definition
public
Term
If you were writing a class declaration for a class named Canine and wanted to palce it in its own file, what should you name the file?
Definition
Canine.cpp
Term
When a structure variable is created its members can be initialized with either a(n) ______ or a(n) ________.
Definition
initialization list, constructor
Term

An inventory structure is declared as follows:

struct {

    int itemCode;

    int qtyOnHand;

};

 

Write a definition statement that creates an Inventory variable named trivet and initializes it with an initialization list so that its code is 555 and quantity 110. 

Definition
Inventory trivet = {555, 110};
Term

Declare a structure named TempScale, with the following members:

farenheight: a double

celsius: a double

Definition

struct TempScale{

    double farenheight;

    double celsius;

};

Term
What are the 5 major components of a computer?
Definition
CPU, main memory (RAM), secondary storage devices, input devices, output devices.
Term
What does the linker do? compared to the compiler and preprocessor.
Definition
The linker creates an executable file after combining the object file (the code you wrote) and the library routines(which the preprocessor took care of)
Term
What's the difference between the object file and the executable file?
Definition
The object file has the machine instructions (generated by the compiler) and the executable file is all the code ready to be executed.
Term
What is a literal?
Definition
data written directly into the program. Literals can be variables (number = 5) or an integer literal (int apples) or string literals ("this is a string literal") or other things.
Term

How many bytes of memory do each of these hold (give explanations for each):

  • 'Q'
  • "Q"
  • "Sales"
  • '\n'
Definition
  • 'Q' is one byte of memory since it's a character literal. 
  • "Q" is two bytes because it is stored as Q and then the null terminator, \0. 
  • "Sales" uses 6 bytes, one byte for each character and then the null terminator, \0. 
  • '\n' is one since it's a character in this case. 
Term
What is the << operator called?
Definition
stream extraction operator
Supporting users have an ad free experience!