C++ How to Program (10th Edition)
10th Edition
ISBN: 9780134448237
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 4, Problem 4.19E
(Find the Two Largest Numbers) Using an approach similar to that in Exercise 4.17, find the two largest values among the 10 numbers. You must input each number only once.]
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
1. Use if - else elif
Read 4 numbers from the user and check the following.
() If the 15t number is less than 2n number, print cube of both the numbers.
(i) If the 2nd number is more than 3° number, print the square of both the numbers.
(ii) Otherwise print ('Four numbers')
(Financial: credit card number validation) Credit card numbers follow certain pat-
terns. A credit card number must have between 13 and 16 digits. It must start with:
4 for Visa cards
5 for Master cards
37 for American Express cards
6 for Discover cards
In 1954, Hans Luhn of IBM proposed an algorithm for validating credit card
numbers. The algorithm is useful to determine whether a card number is entered
correctly or whether a credit card is scanned correctly by a scanner. Credit card
numbers are generated following this validity check, commonly known as the
Luhn check or the Mod 10 check, which can be described as follows (for illustra-
tion, consider the card number 4388576018402626):
1. Double every second digit from right to left. If doubling of a digit results in a
two-digit number, add up the two digits to get a single-digit number.
4388576018402626
→ 2 * 2 = 4
→ 2 * 2 = 4
→ 4 * 2 = 8
→ 1 * 2 = 2
6 * 2 = 12 (1+ 2 = 3)
→ 5 * 2 = 10 (1+ 0 = 1)
→ 8 * 2 = 16 (1 + 6 = 7)
→ 4 * 2 = 8
How many numbers from 1 - 999 have:1) all three digits the same?(assume that "1" is represented as "001" for this exercise)2) exactly two digits the same? (assume that "1" is representedas "001" for this exercise)
Chapter 4 Solutions
C++ How to Program (10th Edition)
Ch. 4 - (Correct the Code Errors) Identity and correct the...Ch. 4 - (What Does this Program Do?) What does the...Ch. 4 - For Exercises 4.13—4.16, perform each of these...Ch. 4 - For Exercises 4.13—4.16, perform each of these...Ch. 4 - For Exercises 4.13—4.16, perform each of these...Ch. 4 - For Exercises 4.13—4.16, perform each of these...Ch. 4 - (Find the largest) The process of finding the...Ch. 4 - (Tabular Output) Write a C++ program that uses a...Ch. 4 - (Find the Two Largest Numbers) Using an approach...Ch. 4 - (Validating User Input) The examination-results...
Ch. 4 - (What Does this Program Do?) What does the...Ch. 4 - (What Does this Program Do?) What does the...Ch. 4 - (Dangling-else Problem)C++ compliers always...Ch. 4 - (Another Dangling-else Problem) Based on the...Ch. 4 - (Another Dangling-else Problem) Based on the...Ch. 4 - (Square of Asterisks) Write a program that reads...Ch. 4 - (Palindromes) A palindrome is a number or a text...Ch. 4 - (Printing the Decimal Equivalent of a Binary...Ch. 4 - (Checkerboard Pattern of Asterisks) W rite a...Ch. 4 - (Multiples of 2 with an Infinite Loop) write a...Ch. 4 - (Calculating a Circle’s Diameter, circumference...Ch. 4 - What’s wrong with the following statement? Provide...Ch. 4 - (Sides of a Triangle) Write a program that reads...Ch. 4 - (Sides of a Right Triangle) Write a program that...Ch. 4 - (Factorial) The factorial of a nonnegative integer...Ch. 4 - (Modified Account Class) Modify class Account...Ch. 4 - (Enforcing Privacy with Cryptography) The...Ch. 4 - (World Population Growth) World population has...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Apply the normalization process to the Veterinary Office ListVersion One relation shown in Figure 1-34 (see pag...
Database Concepts (8th Edition)
Give a Java statement that will display a dialog window on the screen with the message I Love You.
Java: An Introduction to Problem Solving and Programming (8th Edition)
Are reflex actions (such as flinching from a hot stove) rational? Are they intelligent?
Artificial Intelligence: A Modern Approach
If the following statement were used in a Java program, it would cause something to be written to the screen. W...
Absolute Java (6th Edition)
Computers process data under the control of sets of instructions called
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
An online or hard-copy repository for all project correspondence, inputs, outputs, deliverables, procedures, an...
Essentials of Systems Analysis and Design (6th Edition)
Knowledge Booster
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
- (Numerical) Using the srand() and rand() C++ library functions, fill an array of 1000 floating-point numbers with random numbers that have been scaled to the range 1 to 100. Then determine and display the number of random numbers having values between 1 and 50 and the number having values greater than 50. What do you expect the output counts to be?arrow_forward(General math) The value of p can be approximated by this series: 4(113+1517+....) Using this formula, write a program that calculates and displays the value of , using 2, 3, and 4 terms of the series.arrow_forwardFind the error(s) in the following code: (6)arrow_forward
- A and BonlyIn this program, you are asked to write a program in assembly which works as a simple calculator.The program will get two integer numbers, and based on the requested operation, the result shouldbe shown to the user.a. The program should print a meaningful phrase for each input, and the result.i. “Enter the first number”ii. “Enter the second number”iii. “Enter the operation type”iv. “The result is”b. The user should enter 0, 1, and 2 to tell the program the types of operation add, sub, andmultiply, respectively.c. How many registers do you need to implement this program?d. What system calls do you need to write this program?arrow_forwardgiven integer d) HWFactors) Write a program to input a number from user and find all factors of the given number e) Evaluation (Factorial of a Number) Write a program that calculates the factorial of a number using one of the repetition statements that you have learn. Example the factorial of number 3 is 6 (because: 1 x 2 x 3 = 6).arrow_forwardParking Charges) A parking garage charges a $2.00 minimum fee to park for up to threehours and an additional $0.50 per hour for each hour or part thereof over three hours. The maximumcharge for any given 24-hour period is $10.00. Assume that no car parks for longer than 24 hoursat a time. Write a program that will calculate and print the parking charges for each of three customers who parked their cars in this garage yesterday. You should enter the hours parked for eachcustomer. Your program should print the results in a tabular format, and should calculate and printthe total of yesterday's receipts. The program should use the function calculateCharges to determine the charge for each customer. Your outputs should appear in the following format:Car Hours Charge1 1.5 2.002 4.0 2.503 24.0 10.00TOTAL 29.5 14.50arrow_forward
- H. W1: - Write a program to find the summation of n terms from the following series. x2 x6 Sum .... to n term y11 H. W2: - Write a program to find the summation of the following series. Sum = 5+112² + 175 + 237 + 299arrow_forward1) Simple Calculator: In Python, implement a simple calculator that does the following operations: summation, subtraction, multiplication, division, sqrt, power, natural log and abs. a) Follow the instructions below: To work with the calculator, the user is asked to enter the first number, then the operation, and finally, a second number if required. Your code has to recognize the need for the second number and ask for it if required. After performing one operation, the calculator prints the output of the operation. After performing one operation, the calculator must not exit. It has to start again for the next operation. The calculator will be closed if the user writes 'e' as any input. Use functions to perform the operations and the appropriate conditions to prevent common errors such as entering characters as one of the numbers etc. b) Run your code and provide the results for at least one example per operation. - -arrow_forward(a && b) || (c&&d) only gives true when: any of a, b, c, d is true both a,b are true all, a, b, c, d are true a,b is ture or c.d is true O None of abovearrow_forward
- Determine the largest and smallest integers in a group of three integers. Program requirements: 1. Declare integer variables for the three integers. 2. Prompt the user using printf and read all three integers from the user using scanf. (You can do it one by one, so three prompts in total). 3. Determine which of the three numbers is the smallest and which is the largest using as many if or if...else statements as necessary. 4. Print in the screen the smallest integer using printf. 6. Print in the screen the largest integer using printf. Hint: You can declare integer variables “smallest” and “largest” to keep track as you make comparisons. The following is an example of how your program should look when you execute it: Give me the first integer: 4 Give me the second integer: 3 Give me the third integer: 5 The smallest integer of the group is: 3 The largest integer of the group is: 5 In C please, Thank youarrow_forward(c) Use an adjaceney matrix to represent the pseudograph shown in the following figure.arrow_forwardAlert dont submit AI generated answer.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Literals in Java Programming; Author: Sudhakar Atchala;https://www.youtube.com/watch?v=PuEU4S4B7JQ;License: Standard YouTube License, CC-BY
Type of literals in Python | Python Tutorial -6; Author: Lovejot Bhardwaj;https://www.youtube.com/watch?v=bwer3E9hj8Q;License: Standard Youtube License