CMSC 140 MIDTERM EXAM REVIEW QUESTIONS AND ANSWERS, GRADED A+| latest update 2024/25|
CMSC 140 MIDTERM EXAM REVIEW QUESTIONS AND ANSWERS, GRADED A+ What kind of error occurs when something wrong in the "grammar" of the program keeps it from compiling? - -Syntax Error What kind of error occurs when the program runs, but it gives you the wrong result? - -Logical Error What kind of error occurs when the program runs until a certain line of code and then crashes? - - Runtime Error Define a constant variable of double type named PI that has an initial value of 3.14159. - -const double PI = 3.14159; Code the following statements using combined assignment operators: 1. price1 is equal to price1 plus 5. 2. price2 is equal to price2 times 7.0 3. price3 is equal to price3 divided by 4.5 4. totalPrice is equal to totalPrice modulus 3 Hint: Things like an equal sign or multiply sign but initialize the variables. - -double price1 = 3.45, price2 = 5.79, price3 = 15.64; int totalPrice = 98; //1. price1 += 5; //2. price2 *= 7.0; //3. price3 /= 4.5; //4. totalPrice %= 3; What does the following code output to the user? int A = 10, B = 17, C = 2; double D = 17.01; bool boolValue = true; if (A > B) { cout << "Good afternoon, sir." << endl; if (A == C) { cout << "Fine weather today we're having." << endl; } } else if (D < B) { cout << "It looks like it will rain later on." << endl; } else { cout << "Good morning." << endl; if (boolValue == true) { cout << "The sun's bright at this time." << endl; } else { cout << "We've got a lot of cloud cover now." << endl; } } - -//The code outputs: //Good morning. //The sun's bright at this time. What does the following code ouput to the user? int num1 = 10, num2 = 13, num3 = 10, square, q
Written for
- Institution
- CMSC
- Course
- CMSC
Document information
- Uploaded on
- May 9, 2024
- Number of pages
- 9
- Written in
- 2023/2024
- Type
- Exam (elaborations)
- Contains
- Questions & answers
Subjects
-
cmsc 140 midterm exam review questions and answe
Also available in package deal