click below
click below
Normal Size Small Size show me how
CSE 232 SE 1
summer exam one study stack
| Question | Answer |
|---|---|
| When should you use a post fix increment instead of a prefix increment | When you need the value returned by the expression to be the pre-increment value |
| Which of the following is a bitwise opera tor? | operator& |
| Which of the following operations can you do with a constant variable? | You can do two of the above (I think it is initialize and print) |
| An identifier that is not declared inside any other construct has what scope? | global |
| Which of the following is NOT a benefit to using curly braces for initialization? | Allows const variables to be initialized |
| Why should undefined behavior be avoided? | Because it means that your programs could do anything |
| What is the value of x? bool x0123 == 83; | true |
| Which of the following is equivalent to this statement? Note, the type of other isnt specified. double const d{other}; | const double d{other}; |
| What is the value of x? int y = 200; int x = (45 <= y <= 100); | 1 |
| What is the result of the expression 10 / 3? | 3 |
| Which of the following expressions generate type errors? | (a) 0xAA + 5 (b) 054 + 2 (c) 5.6 + 3 (d) All of (a-c) generate type errors. (e) None of (a-c) generate type errors--RIGHT ANSWER |
| Why (generally) should you avoid starting integer with leading zeros (i.e. 0099) | leading zeros indicate octal literals |
| What is printed by the following code? char x = a + 2; std::cout << x; | c |
| Assessing the value of an uninitialized int causes what to happen? | undefined behavior |
| Which of the following is equivalent to the C++ expression: (0 <= x < 7) | (0 <= x) < 7 |
| What does the following code output? char c = 'a'; char d, e; d = e = c; c ='b'; cout << c << d << e; | baa |
| What is the path of the root directory? | / |
| What is this programs output? int x = 3, y = 2; y = x++ + y; y *= 2; cout << y / x; | 2 |
| When declaring an int, what is its initial value? | undefined |
| The clang-format tool adjusts what prop erty of the files it is given? | It adjusts the whitespace (indentation and spacing) |
| What is the value of y after these lines are run in C++? int x = 3; double y = x / 4; | 0 |
| Assuming that x, y, and z are all defined as integers, which of the following is true in C++: | !!y will turn y into a 0 or 1 (false or true) through double negation. |
| What is the value of b after the following code executes? int a = 2; int b = 4 * a; std::cout << (b += 2); | 10 |
| What is the output of the following code? int x = 1, y = 2; std::cout << (++x * y++) << std::endl; | 4 |
| What is the value of y? double y = 13 / 2; | 6.0 |
| What symbol/identifier denotes the home directory? | ~ |
| What is the value of x in the following pro gram? auto x = 'b'- 'a'; | 1 |
| Which of the following are legal comments in C++ | (a) //// This is a legal comment (b) All of the above-THE ANSWER (c) //--- This is a legal comment---// (d) // This is a legal comment (e) /* This is a legal comment */ |
| Why does the following code generate a compiler error? char c ='0'; cin >> c; cout << ++c; | no error, code should compile. |
| how large is an int | depends on the system |
| What is NOT included when initializing a variable? | (a) The variables name (b) The variables type (c) None of the above-CORRECT ANSWER (d) The variables value |
| Which of the following types is largest? | Depends on compiler/OS. |
| cd .. changes your current working direc tory to what directory? | The parent directory |
| On my system, when I call sizeof(bool); I get the value 1. What does this mean? | It means that a bool takes up one byte. |
| For which values of int x will the following expression be true?-2 < x <= 2 | (a)-2,-1, 0, 1 (b) None exist (c)-1, 0, 1, 2 (d)-2,-1, 0, 1, 2 (e)-1, 0, 1 (f) All possible values of x-CORRECT ANSWER |
| Which of the following is NOT a binary op erator? | e) ++ |
| What is wrong with this function invoca tion? std::cout << Func(int x, &y); | Arguments shouldnt have a type dec laration |
| Accessing the value of an uninitialized char variable will result in what? | undefined behavior |
| What does the std::endl object do when passed as the second operand to the put to (<<) operator? | It causes a newline character to be written to the stream |
| What arguments is this function being called with? int x = 4; int y = 17; Func(++x, y--); | 5 and 17 |
| How do you make a variable that can have multiple types? | It is impossible |
| What is the type of x? auto x = MyFunction("abcd"); | Impossible to determine with the in formation given |
| What is the value of y after these lines are run in C++? int x = 3; double y = x / 4; | 0 |
| If a function is said to be overloaded, that means that there are two functions that share what property? | The same name |
| Which of the following types are NOT fun damental types? | (a) double (b) bool (c) char (d) unsigned (e) int (f) None of the above-CORRECT ANSWER |
| What distinguishes the pre x increment op erator from the post x increment operator? | The prefix increment returns the value after the increment occurs. |
| Curly braces in initialization (e.g. int x {7};), have what advantage over '=' ini tialization (e.g. int x = 7;)? | Implicit narrowing conversions are disallowed. |
| When should you use type inference? | b) When the type of the initializer isnt obvious(c) The variable has local scope. (d) When you want to be explicit about a variables range or precision.(e) When you want to make the type clearly visible to readers.(f) None of the above CORRECT ANSWER |
| The const in an initialization implies what characteristic of the variable is constant? | Its value |
| Which of the following declarations follow the East const Style ? | e) Thing const t; |
| The-i" flag when given to clang-format changes its behavior in what way | It replaces the le with the formatted version. |
| What is the result of the following expres sion? 7 % 5 | 2 |
| If your current working directory is named Lectures , which is located in a folder named CSE232 . How do you change the current working directory to be CSE232 ? | cd .. |
| The clang-format tool adjusts what prop erty of the les it is given? | It adjusts the whitespace (indentation and spacing). |