Chapter 3 IM Answers

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

Info icon This 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
Image of page 1

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

View Full Document Right 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
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
Image of page 3

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

View Full Document Right 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
Image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern