Podcast
Questions and Answers
When one control statement is located within another, it is said to be ________.
When one control statement is located within another, it is said to be ________.
nested
What is the significance of \n
and \t
in C++?
What is the significance of \n
and \t
in C++?
- They are arithmetic operators.
- They are examples of escape sequences. (correct)
- They are loop control statements.
- They are used for variable declarations.
Given the array declaration int myArray[12] = {1,2,3,6,5,4,7,1,2};
, how many indexed variables does the array have?
Given the array declaration int myArray[12] = {1,2,3,6,5,4,7,1,2};
, how many indexed variables does the array have?
12
In the statement cout << *p1;
, what does the *
symbol signify?
In the statement cout << *p1;
, what does the *
symbol signify?
If a while
loop's condition never becomes false, a deadlock will occur.
If a while
loop's condition never becomes false, a deadlock will occur.
In a switch
statement, if the value of the expression does not match any of the case values, the statements following the ________ label execute.
In a switch
statement, if the value of the expression does not match any of the case values, the statements following the ________ label execute.
To use functions for manipulating C-style strings, what library must be included in C++?
To use functions for manipulating C-style strings, what library must be included in C++?
In C++, what is ::
called?
In C++, what is ::
called?
A ________ is a way of changing a value of one type to a value of another type.
A ________ is a way of changing a value of one type to a value of another type.
The <<
operator always follows the cin
object, and the >>
operator follows the cout
object.
The <<
operator always follows the cin
object, and the >>
operator follows the cout
object.
By default, what is the access level for all members of a class?
By default, what is the access level for all members of a class?
When is a variable passed by reference?
When is a variable passed by reference?
To use setw
, you need to #include
the ________ library.
To use setw
, you need to #include
the ________ library.
When more than one function has the same name, they are called ________ functions.
When more than one function has the same name, they are called ________ functions.
The ________ of a variable is where that variable can be used.
The ________ of a variable is where that variable can be used.
Flashcards
Nested control statement
Nested control statement
When a control statement is located inside another.
Escape sequences
Escape sequences
Newline and tab
Array size
Array size
The number of elements the array can hold, specified during declaration.
- operator (in cout << *p1;)
- operator (in cout << *p1;)
Signup and view all the flashcards
Infinite loop
Infinite loop
Signup and view all the flashcards
switch Statement's Default
switch Statement's Default
Signup and view all the flashcards
Include for C-strings
Include for C-strings
Signup and view all the flashcards
:: in C++
:: in C++
Signup and view all the flashcards
Changing a variable's data type
Changing a variable's data type
Signup and view all the flashcards
<< operator
<< operator
Signup and view all the flashcards
Default class member access
Default class member access
Signup and view all the flashcards
Passing a variable
Passing a variable
Signup and view all the flashcards
Library for setw
Library for setw
Signup and view all the flashcards
Functions with the same name
Functions with the same name
Signup and view all the flashcards
Variable's Visibility
Variable's Visibility
Signup and view all the flashcards
Study Notes
Exam 1 Review General Concepts
- Exam 1 covers chapters 1, 2, 3, 4, 5, the structures and classes section of chapter 6, and the pointers part of chapter 10.
- Material from the book, labs, and slides is relevant
Fill-in-the-Blanks
- When a control statement is inside another, it is nested.
- \n (newline) and \t (tab) are examples of escape sequences.
- The array
int myArray[12]={1,2,3,6,5,4,7,1,2}
has 12 indexed variables. - In
cout << *p1;
, the*
is the dereference operator. - A(n) infinite loop may occur if nothing within a while loop causes the condition to become false.
- In a switch statement, statements after the default label execute if no case values match.
- To use functions for manipulating c-strings, the
<cstring>
library must be included. - In C++,
::
is the scope resolution operator. - Casting is changing a value's type to another type.
- The extraction operator
>>
followscin
, and the insertion operator<<
followscout
. - Class members are private by default.
- If a variable is passed by reference, changes to the formal parameter affect the actual parameter.
- To use
setw
, the<iomanip>
library must be included. - Functions with the same name are overloaded functions
- The scope of a variable determines where it can be used.
- The six comparison operators in C++ are:
==
(equal to)!=
(not equal to)<
(less than)>
(greater than)<=
(less than or equal to)>=
(greater than or equal to)
True or False
- False, the amount of memory depends on both the number of elements and the size of each element.
- True
- False, C-strings are character arrays, while string objects are instances of the
string
class, offering more functionality. - True
- False,
p2
is an integer. - False, the order of arguments must match the order of parameters.
- True
- True
- True
- False, it will output just 5.
- True
Code Problems
- Write a function named
divide
that takes two integers and returns the first divided by the second. - Add code to the
divide
function so the second integer has a default value of 5. - Write C++ code that reads an integer from the user, passes it as a pointer to a function named
absoluteValue
, and updates the original integer with its absolute value. - Write a void function with two integer call-by-reference parameters that output the sequence 6, 12, 18, 24.
- Write a class definition for a
Table
with members for name, material, length, and width, including mutator and accessor functions. - Write a program that defines a function to populate an array with a series of positive and negative integers, then another function to separate these into two arrays (positive and negative) and print their contents.
Debugging
- Find and correct all five errors in a given C++ program designed to print a reversed c-string.
Fill-In-The-Blanks (Code Completion)
- Complete a function call to
myFunction(int i, char j, string k)
with valid arguments. - Complete code to output "beep" using a loop that iterates through a string.
- Complete code that sets a pointer and outputs the value 12 after some pointer manipulation:
int *ptr2 = &y;
*ptr1 = ptr2;
*ptr2 = 12;
cout << *ptr1 << endl;
- Complete the program to input and output name and student ID:
getline(cin, myClass[i].name);
Code Evaluation
- Determine the exact output of various small C++ programs, considering data types and order of operations.
- Pay close attention to whether the output is an integer or a decimal-based number.
- Consider operator precedence and data type conversions which determine the final output.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
Review key concepts for Exam 1, covering chapters 1 through 6 (structures and classes) and chapter 10 (pointers). Focus on materials from the textbook, lab exercises, and lecture slides. Key topics include nested control statements, escape sequences, arrays, and operators.