C857 Test Questions & Answers(RATED A)
variable -ANSWER named location in memory main function -ANSWER called when the program starts cout -ANSWER a filestream variable that represents the default output device #include iostream -ANSWER include directive needed to allow use of the various I/O operators such as cout and cin. preprocessor directive -ANSWER C program line beginning with # that provides an instruction to the preprocessor; instruction to the compiler to change the source code before compilation. how to enable printing of output (C++) -ANSWER #include iostream using namespace std; endl -ANSWER a stream manipulator that can be used to advance the cursor to the next line on the computer screen; starts new output line cin -ANSWER a filestream variable that represents the default input source block comment -ANSWER Multiline (usually) comment; enclosed between /* and */ over multiple lines in the source code. literal -ANSWER a specific value in code, like 2 include statement and namespace statement needed to use e.g. cout, cin, endl -ANSWER #include iostream using namespace std; approximate max value that int can handle -ANSWER ~2 billion (2,000,000,000) When the / operands are integers, the division operator / performs integer division, throwing away any ______ -ANSWER When the / operands are integers, the division operator / performs integer division, throwing away any remainder. Examples: 24 / 10 is 2. 50 / 50 is 1. 1 / 2 is 0. 2 divides into 1 zero times; remainder of 1 is thrown away. const -ANSWER Make a variable unmodifiable. When a variable represents a literal, the variable's value should not be changed in the code. If the programmer precedes the variable declaration with the keyword ____, then the compiler will report an error if a later statement tries to change that variable's value. include statement for standard math library -ANSWER #include cmath implicit conversion -ANSWER the automatic transformation of one data type to another For an arithmetic operator like + or *, if either operand is a double, the other is automatically converted to double, and then a floating-point operation is performed. For assignment =, the right side type is converted to the left side type. -int-to-double conversion is straightforward: 25 becomes 25.0. -double-to-int conversion just drops the fraction: 4.9 becomes 4 static_cast operator -ANSWER explicitly converts (or type casts) data from one data type to another A programmer can precede an expression with static_casttype(expression) to convert the expression's value to the indicated type. include statement for standard string library -ANSWER #include string how to read an input string containing spaces using getline -ANSWER getline(cin, stringVar) using rand() with modulo to generate random value limited to certain number of values -ANSWER Generally, rand() % N yields N possible values, from 0 to N-1. srand() -ANSWER Seeds the random number generator a C++ built-in function used to initialize the rand function
Document information
- Uploaded on
- January 26, 2024
- Number of pages
- 8
- Written in
- 2023/2024
- Type
- Exam (elaborations)
- Contains
- Questions & answers