C++ for Engineers and Scientists
4th Edition
ISBN: 9781133187844
Author: Bronson, Gary J.
Publisher: Course Technology Ptr
expand_more
expand_more
format_list_bulleted
Question
Chapter 4.2, Problem 3E
Program Plan Intro
- The main() function is used to perform all the task.
- Declare the variable first_number and second_number of int type.
- The cout statement used to print line on console.
Program description:
The following program will input two number and if first number is greater than second then print “The first number is greater”, else print “The first number is smaller”.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
(Pass or fail) Write a c++ program that prompts a student to enter a score.If the score is greater or equal to 60, display “you pass the exam”; otherwise, display “you don’t pass the exam”.Your program ends with input -1.Here is a sample run:Enter your score: 80You pass the exam.Enter your score: 59You don’t pass the exam.Enter your score: -1No numbers are entered except 0
(Guess the Number) Write a C program that plays the game of “guess the number” as follows: Your program chooses the number to be guessed by selecting an integer at random in the range1 to 1000. The program then types:I have a number between 1 and 1000.Can you guess my number?Please type your first guess.
(C prog. language)
Chapter 4 Solutions
C++ for Engineers and Scientists
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
- CODE USING C++ 1. Squares by CodeChum Admin Looping random numbers and manipulating those values are fun, too! Why don't we try one that returns the square of an inputted number repeatedly until the user inputs 0? Let's do this! Instructions: Using a do...while() loop, continuously scan for random integers that will be inputted by the user and print out its square, separated in each line. Once the inputted value is 0, it will still print out its square value but should then terminate the loop afterwards. Use this concept in making your loop condition. Input Multiple lines containing an integer. 2 6 0 Output Multiple lines containing an integer. 4 36 0arrow_forward(c) Write a program that asks the users to calculate volume of a rectangular prism, in cm², where the user needs to key in the value of length, width and height. The formula for the volume of a rectangular prism is given by: volume = length x width x height If the calculated volume is more than 100 cm², display a message indicating that the size of this rectangular prism is too big. If the calculated volume is less than 20 cm², display a message indicating that the size of this rectangular prism is too small. However, if the volume is in between 20 cm³ and 100 cm², display a message indicating that the size of this rectangular prism is moderate.arrow_forward(Factorials) The factorial function is used frequently in probability problems. The factorialof a positive integer n (written n! and pronounced “n factorial”) is equal to the product of the positive integers from 1 to n. Write a program that evaluates the factorials of the integers from 1 to 5.Print the results in tabular format. What difficulty might prevent you from calculating the factorialof 20?arrow_forward
- (b) The following equations are used to calculate the voltage and power of a load in an electric circuit: Voltage of a load, V = IR Power of a load, P = 1²R (i) Draw a flowchart of a program which allows user to input the current (I) and resistance (R) of a load. The program is required to provide selections for the user to calculate either the voltage (V) or power (P) of the load. The program should also output the message "Invalid Selection" if the user makes invalid choice. (ii) Based on the flowchart above, write a complete program in C.arrow_forwarddo not submit this one) Write a C++ program that reads in a length in feet and inches and outputs the equivalent length in meters and centimeters. Use at least three functions: one for input, one or more for calculating, and one for output. Include a loop that lets the user repeat this computation for new input values until the user says he or she wants to end the program. There are 0.3048 meters in a foot, 100 centimeters in a meter, and 12 inches in a foot. (do not submit this one) Write a C++ program like that of the previous exercise that converts from meters and centimeters into feet and inches. Use functions for the subtasks. (submit this one) Write a C++ program that combines the functions in the previous two Practice Programs. The program asks the user if he or she wants to convert from feet and inches to meters and centimeters or from meters and centimeters to feet and inches. The program then inputs the values and performs the desired conversion. Have the user respond by…arrow_forward(USE C++ CODING) Based on the image attached, write the missing statements in the program so that it prompts the user to input two numbers. If one of the numbers is 0, the program should output a message indicating that both numbers must be nonzero. If the first number is greater than the second number, it outputs the first number divided by the second number; if the first number is less than the second number, it outputs the second number divided by the first number; otherwise, it outputs the product of the numbers.arrow_forward
- (Converting a given date to the day number in the year) Write a program that prints the day number of the year, given the date is in the form month day year. For example, if the input is 1 1 05, the day number is 1; if the input is 12 25 05, the day number is 359. The program should check for a leap year. A year is a leap year if it is divisible by 4 but not divisible by 100. For example, 1992 and 2008 are divisible by 4, but not by 100. A year that is divisible by 100 is a leap year if it is also divisible by 400. For example, 1600 and 2000 are divisible by 400. However, 1800 is not a leap year because 1800 is not divisible by 400. Directions: Call 3 functions from your main. One to input data (pass parameters in a list) One to determine the result (use a value returning function to determine and return the result) One to display both the date and the result You can use two Python dictionaries to represent the number of days in each month for a regular and a leap year. Ex.…arrow_forward(Using Visual Basic language) Marketing Terms? The markup of an item is the difference between its selling price and its purchase price. Two other marketing terms are percentage markup=makeup/(purchase price) and profit margin= makeup/(selling price) where the quotients are expressed as percentages. Write a program that computes the markup, percentage markup, and profit margin of an item. Note: The output format of your program should be exactly the same as given below One possible outcome: Enter purchase price: 215 Enter selling price: 645 Markup: $430.0 Percentage markup: 200.0% Profit margin: 66.67%arrow_forward(Electrical eng.) a. The voltage gain of an amplifier is given by this formula: voltagegain=[275 23 2 +0.5 f 2 ]n f is the frequency in Hz. n is the number of stages in the amplifier. Using this formula, write, compile, and run a C++ program to determine the value of the voltage gain for a four-stage amplifier operating at a frequency of 120 Hz. Your program should produce the following display: At a frequency of xxxxx hertz, the voltage gain is yyyyy Your program should replace xxxxx with the frequency and yyyyy with the voltage gain. b. Manually check the value your program produces. After verifying that your program is working correctly, modify it to determine the voltage gain of a 12-stage amplifier operating at a frequency of 9500 Hz.arrow_forward
- (python) Create a program that “makes change” for the user. The user will input two numbers, one is the amount charged and the other is the amount given. The program will determine the amount of change returned based on our currency. It should return the bills (if any) and the coins. Example: Charged $2.35 and paid with $3.00 Returned $0.65 2 quarters ($0.25) 1 dime ($0.10) 1 nickel ($0.05) NOTE: To make this a little easier, we will assume you never charge more than $20 and pay more than $20. Requirements First task is not directly writing code. Create the Pseudo-code to solve this problem. This is a combination of code and english used to solve the problem before actually writing code. This can be used as the comments for your program. Include a comment to the top of the Python code. The comment must include the following: Your name Course name and project name Date completed The program accepts two numbers, both floats. These values should be stored in appropriately named…arrow_forwardPlease, my dear brother, help me do this job. write a suitable code in c++ language only that do the required in the photo only : Please, I want the solution to this code in one code that works and applies to all the conditions in the picture. Thank youarrow_forward-Program C 3. Negative Allergy by CodeChum Admin Whole numbers are great, but I think we should also pay attention to decimal numbers, too. So, how about we make a program that involves a lot of decimals? Instructions: Continuously ask for floating point values (decimal numbers) using the do…while() loop, sum them all up, and store the total into one variable. The loop shall only terminate for the following reasons: A negative decimal number is inputted (but still included in the total sum) The total sum reaches 100.0 or more Input 1. A series of float numbers Output The first multiple lines containing message prompts for float numbers. The last line contains the sum with 2 decimal places. Enter·a·number:·1.1 Enter·a·number:·1.2 Enter·a·number:·1.3 Enter·a·number:·1.4 Enter·a·number:·-1.0 Sum·=·4.00arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author: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
Boolean Algebra - Digital Logic and Logic Families - Industrial Electronics; Author: Ekeeda;https://www.youtube.com/watch?v=u7XnJos-_Hs;License: Standard YouTube License, CC-BY
Boolean Algebra 1 – The Laws of Boolean Algebra; Author: Computer Science;https://www.youtube.com/watch?v=EPJf4owqwdA;License: Standard Youtube License