CMPSC 201 EXAM 2 (Graded A+ Already)
Relational operators correct answers Are used to compare two values and return a true/false value ==, , =, = , , Logical Operators correct answers -Are used to combine multiple condition and return a single true/false value && (and), || (or), ! (not) File I/O and Stream Variables correct answers File I/O and Stream Variables file #include fstream Declaring Variables in File I/O correct answers Declare an object that will refer to the file. datatype objectName; ifstream inFile; // inFile is just an identifier ofstream outFile; // outFile is just an identifier Types of variable declarations in File I/O correct answers Can declare multiple objects: ifstream inFile, dataIn, fileIn; ofstream outFile, dataOut, fileOut; Stream Variables: initiation correct answers -Must be initialized before it contains valid data Initializing a stream means connecting it to a file -The value of the stream variable can be thought of as the file it is connected to Nested 'if' Statements: Caution correct answers -Proper use of braces -C++ automatically matches an else with the closest if Nested 'if' Statements correct answers The "fix" is to use the braces or to use an empty statement ( ; ) for the body of the else of the inside Switches correct answers switch (integer expression) { case value1: : break; case condition2: : break; default: : break;
Written for
- Institution
- CMPSC 201
- Course
- CMPSC 201
Document information
- Uploaded on
- June 1, 2023
- Number of pages
- 18
- Written in
- 2022/2023
- Type
- Exam (elaborations)
- Contains
- Questions & answers
Subjects
Also available in package deal