C++ Programming Exam 1
if (x = 0) x = x + 1; else if (x = 1) x = x + 2; - Answer- x = 2 if (x = 0) x = x + 1; if (x = 1) x = x + 2; - Answer- x = 4 What is the final value of x after performing the following operations? int x = 21; double y = 6; double z = 14; y = x / z; x = 5.5 * y; - Answer- 8 explicit conversion - Answer- the data type transformation caused using a cast operator int x = (float) 5 + 11.25 =16.25 unary cast operator - Answer- a way to create a temporary value that is a floating point number average = ( float ) total / counter; truncated - Answer- Dividing two integers results in integer division in which any fractional part of the calculation is truncated (i.e. lost) implicit conversion - Answer- int x = 6 + 14.45 = 20 double x = 6 + 14.45 =20.45 the expression --(abc * 37): is and why? - Answer- is a syntax error as cannot apply increment or decrement on expression what is not specified by the following correct code segment: for ( c = 1; c = 10; c++ ) - Answer- body statement of loop
Document information
- Uploaded on
- September 5, 2023
- Number of pages
- 10
- Written in
- 2023/2024
- Type
- Exam (elaborations)
- Contains
- Questions & answers