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;
Escuela, estudio y materia
- Institución
- CMPSC 201
- Grado
- CMPSC 201
Información del documento
- Subido en
- 1 de junio de 2023
- Número de páginas
- 18
- Escrito en
- 2022/2023
- Tipo
- Examen
- Contiene
- Preguntas y respuestas
Temas
Documento también disponible en un lote