Chapter 3 IM Answers

Chapter 3 IM Answers - An Introduction to Programming with...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
An Introduction to Programming with C++: Fifth Edition 978-1-4188-3618-4 Chapter 3 Answers CONCEPT LESSON QUESTIONS 1. B Code the algorithm into a program. 2. D Syntax 3. C double payRate = 0.0; 4. C ; (semicolon) 5. C streams 6. B cout 7. A cin 8. C cout << “Hello”; 9. A >> 10. B cin >> currentPay; 11. C endl 12. A evaluate and modify (if necessary) the program 13. C debugging 14. D a syntax error 15. C logic 16. D none of the above 17. D using std::cout; 18. A function header 19. B #include <iostream> 20. A braces
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
EXERCISES – PENCIL AND PAPER 1. IPO chart information C++ instructions Input first number second number Processing Output sum Algorithm 1. enter the first number and the second number 2. calculate the sum by adding the first number to the second number 3. display the sum double num1 = 0.0; double num2 = 0.0; double sum = 0.0; cout << “Enter first number: ”; cin >> num1; cout << “Enter second number: ”; cin >> num2; sum = num1 + num2; cout << “The sum is ” << sum << endl; 2. num1 num2 sum 0.0 3.0 0.0 50.5 0.0 5.0 0.0 31.3 0.0 8.0 0.0 81.8
Background image of page 2
3. IPO chart information C++ instructions Input number of miles driven number of gallons used Processing Output miles per gallon Algorithm 1. enter the number of miles driven and the number of gallons used 2. calculate the miles per gallon by dividing the number of miles driven by the number of gallons used 3. display the miles per gallon double milesDriven = 0.0; double gallonsUsed = 0.0; double milesPerGal = 0.0; cout << “Enter miles driven: ”; cin >> milesDriven; cout << “Enter gallons used: ”; cin >> gallonsUsed; milesPerGal = milesDriven / gallonsUsed; cout << “Miles per gallon: ” << milesPerGal << endl; 4. milesDriven gallonsUsed milesPerGal 0.0 324.0 0.0 200.0 0.0 17.0 0.0 12.0 0.0 19.06 0.0 16.67
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
5. IPO chart information C++ instructions Input yearly taxable wages state income tax rate Processing Output annual state income tax Algorithm 1. enter the yearly taxable wages and the state income tax rate 2. calculate the annual state income tax by multiplying the yearly taxable wages by the state
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 9

Chapter 3 IM Answers - An Introduction to Programming with...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online