Introduction to Programming with C++
Introduction to Programming with C++
3rd Edition
ISBN: 9780133252811
Author: Y. Daniel Liang
Publisher: Prentice Hall
bartleby

Videos

Textbook Question
Book Icon
Chapter 2, Problem 8CP

Translate the following algorithm into C + + code:

Step 1: Declare a double variable named miles with initial value 100.

Step 2: Declare a double constant named KILOMETERS PER MILE with value 1.609.

Step 3: Declare a double variable named kilometers, multiply miles and KILOMETERS_PER_MILE, and assign the result to kilometers.

Step 4: Display kilometers to the console.

What is kilometers after Step 4?

Blurred answer
Students have asked these similar questions
(C PROGRAMMING ONLY) 6. Deal or No Deal?by CodeChum Admin When I was a kid, I used to watch this TV game show, Deal or No Deal? In the game, there are different brief cases, each labeled with a number. Inside each brief case is an amount in Pesos and the goal is to guess which briefcase contains the smallest amount.   In this program, instead of just finding the smallest amount, your task is to ask the user for an integer input and print the values in the array smaller than the inputted integer.   Instructions: In the code editor, you are provided with an array with 100 elements.Your task is to ask the user for an integer input and then print all the elements in the array whose value is lesser than the inputted integer.Input 1. Inputted integer Output Enter value: 6132450351503022244
Two number systems, octal (base 8) and hexadecimal (base 16), are of interest to computer scientists. In fact, in C++, you can instruct the computer to store a number in octal or hexadecimal. The digits in the octal number system are 0,1,2,3,4,5,6, and 7. The digits in hexadecimal number systems are 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E, and F. So A in hexadecimal is 10 in decimal, B is 11 in decimal, and so on. The algorithm to convert a positive decimal number into an equivalent number in an octal (or hexadecimal) is the same for binary numbers. Here, we divide the decimal number by 8(for octal) and by 16(for hexadecimal). Suppose  ab  represents the number a to the base b. For example, 7510 means 75 to the base 10(that is decimal), and 8316 means 83 to the base 16(that is hexadecimal). Then   75310 =13618   and   75310=   2F116* Write a program that uses a recursive function to convert a number in decimal to base 8 or base 16.
Two number systems, octal (base 8) and hexadecimal (base 16), are of interest to computer scientists. In fact, in C++, you can instruct the computer to store a number in octal or hexadecimal. The digits in the octal number system are 0,1,2,3,4,5,6, and 7. The digits in hexadecimal number systems are 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E, and F. So A in hexadecimal is 10 in decimal, B is 11 in decimal, and so on. The algorithm to convert a positive decimal number into an equivalent number in an octal (or hexadecimal) is the same for binary numbers. Here, we divide the decimal number by 8(for octal) and by 16(for hexadecimal). Suppose ab represents the number a to the base b. For example, 7510 means 75 to the base 10(that is decimal), and 8316 means 83 to the base 16(that is hexadecimal). Then   75310 =13618   and   75310=   2F116* Write a program that uses a recursive function to convert a number in decimal to base 8 or base 16.It is necessary that the user enters a nonnegative integer. Check…

Chapter 2 Solutions

Introduction to Programming with C++

Ch. 2 - Prob. 11CPCh. 2 - Prob. 12CPCh. 2 - Prob. 13CPCh. 2 - Prob. 14CPCh. 2 - Prob. 15CPCh. 2 - Are the following statements correct? If so, show...Ch. 2 - Write a statement to display the result of 23.5.Ch. 2 - Suppose m and r are integers. Write a C++...Ch. 2 - How would you write the following arithmetic...Ch. 2 - Prob. 20CPCh. 2 - Prob. 21CPCh. 2 - Which of the following statements are true? a....Ch. 2 - Show the printout of the following code: Ch. 2 - Prob. 24CPCh. 2 - Prob. 25CPCh. 2 - Prob. 26CPCh. 2 - Show the following output; Ch. 2 - If you change in line 12 in Listing 2.10, what...Ch. 2 - Show the printout of the following code: Ch. 2 - How would you write the following arithmetic...Ch. 2 - (Convert Celsius to Fahrenheit) Write a program...Ch. 2 - (Compute the volume of a cylinder) Write a program...Ch. 2 - (Convert feet into meters) Write a program that...Ch. 2 - (Convert pounds into kilograms) Write a program...Ch. 2 - (Financial application: calculate tips) Write a...Ch. 2 - (Sum the digits in an integer) Write a program...Ch. 2 - (Find the number of years) Write a program that...Ch. 2 - (Current time) Listing 2.9, ShowCurrentTime.cpp,...Ch. 2 - (Physics: acceleration) Average acceleration is...Ch. 2 - (Science: calculating energy) Write a program that...Ch. 2 - (Population projection) Rewrite Programming...Ch. 2 - (Physics: finding runway length) Given an...Ch. 2 - (Financial application: compound value) Suppose...Ch. 2 - (Health application: BMP) Body Mass Index (BMI) is...Ch. 2 - (Geometry: distance of two points) Write a program...Ch. 2 - (Geometry: area of a hexagon) Write a program that...Ch. 2 - (Science: wind-chill temperature) How cold is it...Ch. 2 - (Print a table) Write a program that displays the...Ch. 2 - (Geometry: area of a triangle) Write a program...Ch. 2 - (Slope of a line) Write a program that prompts the...Ch. 2 - (Cost of driving) Write a program that prompts the...Ch. 2 - (Financial application: calculate interest) If you...Ch. 2 - (Financial application: future investment value)...Ch. 2 - Prob. 24PE
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Algebraic Expressions – Algebra Basics; Author: TabletClass Math;https://www.youtube.com/watch?v=U-7nq7OG18s;License: Standard YouTube License, CC-BY
Python Tutorial for Beginners 3 - Basic Math, Mathematical Operators and Python Expressions; Author: ProgrammingKnowledge;https://www.youtube.com/watch?v=Os4gZUI1ZlM;License: Standard Youtube License