CSCI 1470: Study Guide 1 Questions

0.0(0)
studied byStudied by 3 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/108

flashcard set

Earn XP

Description and Tags

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

109 Terms

1
New cards
"{" and "}" are called **braces** and they delimit a list or block of statements.

True

False
True
2
New cards
When the CPU is executing an instruction that needs some data, it gets the data from main memory in order to process it.
True
3
New cards
The devices that feed data and programs into computers are called output devices.
False
4
New cards
Information stored in main memory must be transferred to a nonvolatile device for permanent storage.
True
5
New cards
GIGA is a unit prefix in the metric system denoting a factor of one million (1,000,000).
False
6
New cards
Instructions represented as a sequence of 0s and 1s are known as machine instructions.
True
7
New cards
Compilers are programs that automatically translate high-level language programs into executable programs.
True
8
New cards
Assembly language, ALGOL, FORTRAN, C, C++, and Java are all high-level languages.
False
9
New cards
Every C++ program must have a function called main.
True
10
New cards
A reserved word can be used as a variable name.
False
11
New cards
The following is a legal C++ identifier: Hello!
False
12
New cards
The maximum number of significant digits in float values is up to 6 or 7.
True
13
New cards
If a C++ arithmetic expression has no parentheses, operators are evaluated from left to right.
True
14
New cards
The explicit conversion of a value from one data type to another is called type casting.
True
15
New cards
The value of a variable cannot change during program execution.
False
16
New cards
Suppose x = 8. After the execution of the statement y = x+1; y is 9 and x is 9.
False
17
New cards
The escape sequence \\t moves the cursor to the beginning of the next line.
False
18
New cards
In the statement cin >> x;, x can be a variable or an expression.
False
19
New cards
The extraction operator >> skips only leading blank spaces when searching for the next data in the input stream.
False
20
New cards
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
21
New cards
Entering a char value into an int variable causes serious errors, called input failure.
True
22
New cards
In the C++ statement, \n   \n cin.get(u); \n   \n u must be a variable of type char.
True
23
New cards
In an output statement, each occurrence of endl advances the cursor to the end of the current line on an output device.
False
24
New cards
Manipulators without parameters are part of the header file iomanip.
False
25
New cards
For interactive input/output in a program, the program must include the header file iostream.
True
26
New cards
Main memory is called ____.
RAM (Random Access Memory)
27
New cards
Main memory is an ordered sequence of items, referred to as ____.
Memory Locations
28
New cards
When the power is switched off, everything in ____ is lost.

main memory

secondary storage

hard disks

floppy disks
main memory
29
New cards
____ represent information with a sequence of 0s and 1s.

Analog signals

Application programs

Digital signals

System programs
Digital Signals
30
New cards
The digit 0 or 1 is called a binary digit, or ____*.*

bit

bytecode

Unicode

hexcode
bit
31
New cards
ASCII is a standard that defines the numeric codes for ____ characters.

254

128

65536

32768
128
32
New cards
A program called a(n) ____ links together the object files and libraries.

assembler

decoder

linker

compiler
linker
33
New cards
An ____ is a sequence of steps for solving a problem.

algorithm

linker

analysis

design
algorithm
34
New cards
To develop a program to solve a problem, you start by ____.

analyzing the problem

implementing the solution in C++

designing the algorithm

entering the solution into a computer system
analyzing the problem
35
New cards
Which of the following is a reserved word in C++?

char

Char

CHAR

character
char
36
New cards
An example of a floating point data type is ____.

int

char

double

short
double
37
New cards
____ is a valid int value.

46,259

46259

462\.59

\-32.00
46259
38
New cards
The memory allocated for a float value is ____ bytes.

two

four

eight

sixteen
four
39
New cards
The value of the expression 17 % 7 is ____.

1

2

3

4
3
40
New cards
Choose the output of the following C++ statement: \n cout << "Sunny " << '\\n' << "Day " << endl;

Sunny \\nDay

Sunny \\nDay endl

Sunny \n Day

Sunny \\n \n Day
Sunny

Day
41
New cards
____ are output statements that inform the user what to do.

Variables

Prompt lines

Named constants

Expressions
prompt lines
42
New cards
The declaration int a, b, c; is equivalent to which of the following?

inta , b, c;

int a,b,c;

int abc;

int a b c;
int a,b,c;
43
New cards
Suppose that x is an int variable and y is a double variable and the input is: \n   \n 10 20.7 \n   \n Choose the values after the following statement executes: cin >> x >> y;.

x = 10, y = 20

x = 10, y = 20.0

x = 10, y = 20.7

x = 10, y = 21.0
x = 10, y = 20.7
44
New cards
Suppose that x is an int variable, y is a double variable and ch is a char variable and the input is: \n   \n 15A 73.2 \n   \n Choose the values after the following statement executes: \n   \n cin >> x >> ch >> y;

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

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

x = 15, ch = 'a', y = 73.0

This statement results in an error because there is no space between 15 and A.
x = 15, ch = 'A', y = 73.2
45
New cards
Suppose that x is an int variable, ch is a char variable, and the input is: \n   \n 276. \n   \n Choose the values after the following statement executes: \n   \n cin >> ch >> x;

ch = '2', x = 276

ch = '2', x = 76

ch = ' ', x = 276

ch = 'b', x = 76
ch = ‘2’, x = 76
46
New cards
Suppose that alpha is an int variable and ch is a char variable and the input is: \n   \n 17 A \n   \n What are the values after the following statements execute? \n   \n cin >> alpha; \n cin >> ch;

alpha = 17, ch = ' '

alpha = 1, ch = 7

alpha = 17, ch = 'A'

alpha = 17, ch = 'a'
alpha = 17, ch = ‘A’
47
New cards
Suppose that ch1, ch2, and ch3 are variables of the type char and the input is: \n   \n A B \n C \n   \n Choose the value of ch3 after the following statement executes: \n   \n cin >> ch1 >> ch2 >> ch3;

'A'

'B'

'C'

'\\n'
‘C’
48
New cards
Manipulators without parameters are part of the ____ header file.

iostream

iomanip

ifstream

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

100

200

300

320
300
50
New cards
Using functions greatly enhances the program’s readability because it reduces the complexity of the function main. \n       

True

False
True
51
New cards
A function can have zero to many parameters, and it can have ________ return value(s). \n  

zero to many

no

zero or one

a maximum of ten
zero or one
52
New cards
When a function is called, flow of control moves to the function's prototype. \n       

True

False
False
53
New cards
In a value-returning function header line, you are required to furnish \n  

the name of the function

the data type(s) and name(s) of any parameters

the data type of the return value

All of these \n  
All of these
54
New cards
A function's return type must be the same as the function's parameters. \n       

True

False
False
55
New cards
A void function is one that \n  

does nothing useful

has an empty function body

has no parameters

returns no value \n  
returns no value
56
New cards
A  ________ variable is defined inside the body of a function and is not accessible outside that function. \n  

global

reference

local

counter
local
57
New cards
A variable that can be accessed anywhere in the program is said to have  ________ scope. \n  

global

external

local

dynamic
global
58
New cards
Value-returning functions cannot be called in expressions. \n       

True

False
False
59
New cards
When a function just needs to use a copy of an argument passed to it, the argument should normally be passed by \n  

variable

value

reference

design
value
60
New cards
________ parameters allow a function to access and modify the parameter's corresponding argument. \n  

reference

floating-point

integer

undeclared
reference
61
New cards
Values passed to a function are called ________. \n  

parameter

argument

function's value

All of these
argument
62
New cards
A value-returning function should have reference parameters only. \n       

True

False
False
63
New cards
The ________ statement causes a function to end and the flow of control to move back to the point where the function call was made. \n  

end

break

continue

return
return
64
New cards
Files (i.e., file stream objects) should be passed by reference. \n       

True

False
True
65
New cards
A void function is one that \n  

has an empty function body

is never called

returns no value

has no parameters
returns no value
66
New cards
A(n) ________ is information that is passed to a function, and a(n) ________ is a special variable that receives and holds that information. \n  

function call, function header

function prototype, function header

parameter, argument

argument, parameter
argument, parameter
67
New cards
When only a copy of an argument is passed to a function, it is passed ______ \n     

by copy

by reference   

informally

by value
by value
68
New cards
When a function needs to modify the original argument passed to it, for example in order to change its value, the argument needs to be __________ \n  

passed by value

passed into a reference parameter

a static variable

an integer
passed into a reference parameter
69
New cards
Files (i.e., file stream objects) should be passed by value. \n       

True

False
False
70
New cards
A ________ variable is declared outside all functions. \n     

local

global

floating-point

counter
global
71
New cards
A  ________ variable is defined inside the body of a function and is not accessible outside that function. \n  

global

reference

counter

local
local
72
New cards
Given the function prototype:      float cube(float x); \n which of the following statements is a legal function call? \n     

cout << cube;

cout << cube(10.5);

cube();

cout << cube();
cout << cube(10.5);
73
New cards
Given the function prototype:    void print_val(); \n which of the following statements is legal? \n  

cout << print_val;

cout << print_val();

print_val();

cout << print_val(10.5);
print_val();
74
New cards
Given the function definition:

void increment_val(int& val1, float& val2 )
{
val1 = val1 + 1;
val2 = val2 + 1.0;
}

what are the values printed on the screen after the statements below are executed?

int myval = 1;
float yourval = 2.5;
increment_val(myval, yourval);
cout << myval << ' ' << yourval;

1 2.5

2 2.5

2 3.5

1 3.5
2 3.5
75
New cards
A function ________ eliminates the need to place a function definition before all calls to the function. \n  

header

prototype

argument

parameter
prototype
76
New cards
Given the function definition:

void increment_val(int val1, float val2 )
{
val1 = val1 + 1;
val2 = val2 + 1.0;
}

what are the values printed on the screen after the statements below are executed?

int myval = 1;
float yourval = 2.5;
increment_val(myval, yourval);
cout << myval << ' ' << yourval;

1 2.5

2 2.5

2 3.5

1 3.5
1 2.5
77
New cards
A function is executed when it is ________ \n  

defined

prototyped

called

declared
called
78
New cards
A function’s parameter list cannot be empty. \n  

True

False
False
79
New cards
If the parameter list of a function is empty, the parentheses after the function name are not needed. \n  

True

False
False
80
New cards
The execution of a return statement in a user-defined function terminates the function. \n  

True

False
True
81
New cards
It is not necessary to specify the names of parameters in a function prototype. \n  

True

False
True
82
New cards
When writing a function prototype, you do not have to specify the data type of each parameter. \n  

True

False
False
83
New cards
A value-returning function can return two values via the return statement. \n  

True

False
False
84
New cards
The execution of a C++ program always begins with the function main. \n  

True

False
True
85
New cards
It is legal to use a return statement without any value in a user-defined void function. \n  

True

False
True
86
New cards
If a void function has three value parameters, it must have at least two reference parameters. \n  

True

False
False
87
New cards
Any parameter that receives a value and also sends a value outside the function must be declared as a reference parameter. \n  

True

False
True
88
New cards
Whenever the value of a reference parameter changes, the value of the argument changes. \n  

True

False
True
89
New cards
The corresponding argument for a reference parameter can be any expression. \n  

True

False
False
90
New cards
The content of a parameter that is a reference parameter is an address. \n  

True

False
True
91
New cards
A global identifier is an identifier declared outside of every function definition. \n  

True

False
True
92
New cards
Using global variables in a program is a better style than using local variables because extra variables can be avoided. \n  

True

False
False
93
New cards
Functions that do not have a return type are called ____ functions. \n  

zero

null

void

empty
Void
94
New cards
Given the following function prototype: int test(float, char);

which of the following statements is valid? \n  

cout << test(12, &);

cout << test("12.0", '&');

int u = test(5.0, '\*');

cout << test(5.0, "\*");
int u = test (5.0, ‘\*’);
95
New cards
A function prototype is ____. \n  

a definition, but not a declaration

a declaration and a definition

a declaration, but not a definition

a comment line
a declaration, but not a definition
96
New cards
Given the following function prototype: double tryMe(double, double);

which of the following statements is valid? Assume that all variables are properly declared. \n  

cin >> tryMe(x);

cout << tryMe(2.0, 3.0);

cout << tryMe(tryMe(double, double), double);

cout << tryMe(tryMe(float, float), float);
cout << tryMe(2.0, 3.0);
97
New cards
Given the function prototype: double testAlpha(int u, char v, double t);

which of the following statements is legal? \n  

cout << testAlpha(5, 'A', 2.);

cout << testAlpha( int 5, char 'A', double 2);

cout << testAlpha('5.0', 'A', "2.0");

cout << testAlpha(5.0, "65", 2.0);
cout << testAlpha(5, ‘A’, 2.);
98
New cards
Given the function prototype: float test(int, int, int); \n   \n which of the following statements is legal? \n  

cout << test(7, test(14, 23));

cout << test(test(7, 14), 23);

cout << test(14, 23);

cout << test(7, 14, 23);
cout << test(7. 14, 23);
99
New cards
Which of the following function prototypes is valid? \n  

int funcTest( x, y, z);

funcTest(int x, int y, float z);

int funcTest(int x, int y, float z)

int funcTest(int, int, float);
int funcTest(int, int, float);
100
New cards
Given the following function prototype: int myFunc(int, int);

which of the following statements is valid? Assume that all variables are properly declared. \n  

cin >> myFunc(y);

cout << myFunc(myFunc(7, 8), 15);

cin >> myFunc('2', '3');

cout << myFunc(myFunc(7), 15);
cout << myFunc(myFunc(7, 8), 15);