C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN: 9781337102087
Author: D. S. Malik
Publisher: Cengage Learning
expand_more
expand_more
format_list_bulleted
Question
error_outline
This textbook solution is under construction.
Students have asked these similar questions
Assume that the following code is correctly inserted into a program:int num = 1;int count;for (count = 0; count < 5; ++count)num = 2 * num + num % (count + 1);a. What is the final value of num?(i) 15 (ii) 42 (iii) 26 (iv) none of theseb. If a semicolon is inserted after the right parentheses in the for loop statement, what is the final value of num?(i) 1 (ii) 2 (iii) 3 (iv) 4 (v) none of thesec. If 5 is replaced with 0 in the for loop control expression, what is the final value of num?(i) 0 (ii) 1 (iii) 2 (iv) none of these
After the following statements are executed, val should contain a capital letter. Write a while loop to follow the given code that will repeatedly reprompt and reread input if this is not the case. (note that a capital letter is anything >='A' and <= 'Z')
char val;cout<<"Enter a capital letter\n";cin>>val;
5.2: TimeWrite a program that requests the current time and a waiting time as two integers for the number of hours and the number of minutes to wait. The program then outputs what the time will be after the waiting period. Use 24-hour notation for the times. Include a loop that lets the user repeat this calculation for additional input values until the user says she or he wants to end the program.
Input Notes:Both the current time and the waiting time are entered in the form HH:MM where HH and MM are integers signifying hours and minutes respectively. In response to the continuation prompts (described below) the user types a y or a Y to signify "continue" with any other character signifying "quit".
Output Notes (Prompts and Labels):At the outset the program prints the title "Compute completion time from current time and waiting period". The program then prompts for the current time with the prompt "Current time:" followed by the instructions "Enter 24 hour time in the format HH:MM".…
Knowledge Booster
Similar questions
- (Electrical eng.) a. An electrical manufacturer tests five generators by measuring their output voltages at three different times. Write a C++ program that uses a nested loop to enter each generator’s test results, and then computes and displays the average voltage for each generator. Assume the following generator test results: 1stgenerator:122.5122.7123.02ndgenerator:120.2127.0125.13rdgenerator:121.7124.9126.04thgenerator:122.9123.8126.75thgenerator:121.5124.7122.6 b. Modify the program written for Exercise 3a to calculate and display the average voltage for all the generators. (Hint: Use a second variable to store the total of all the generator’s voltages.)arrow_forwardHide Transcribed Text Write c++ a program that will accept a Celsius value between -40 degrees and 100 degrees. The number entered may contain decimal digits. Make these high and low values named constants. Also, make all temperatures floating point numbers and with two decimal digits when displayed. Using a while loop, allow the user to enter the value and if not in range continue to prompt the user for a valid value. Next prompt the user for the number of temperatures to be displayed. In a while loop repeat the following steps: 1. Calculate the Fahrenheit equivalent temperature and Kelvin equivalent temperature. The formulas are: Fahrenheit=9/5×Centigrade +32 Kelvin=Centigrade +273.15arrow_forwardprogram3_3.py A legally qualified automobile driver is at least sixteen and has a license. Write a program that prompts the user for his/her age and licensed status. Then, use nested loops to determine if the user can legally drive. If the user cannot legally drive, the program should report why not.arrow_forward
- C++ Write a while loop that prints userNum divided by 4 (integer division) until reaching 2 or less. Follow each number by a space. Example output for userNum = 160:40 10 2 Note: These activities may test code with different test values. This activity will perform four tests, with userNum = 160, then with userNum = 8, then with userNum = 0, then with userNum = -1. See "How to Use zyBooks".Also note: If the submitted code has an infinite loop, the system will stop running the code after a few seconds, and report "Program end never reached." The system doesn't print the test case that caused the reported message. #include <iostream>using namespace std; int main() { int userNum; cin >> userNum; /* Your solution goes here */ cout << endl; return 0;} This is what I came up with but it produces no outputarrow_forward(1) Prompt the user to enter a string of their choosing. Output the string. (1 pt)Ex: Enter a sentence or phrase: The only thing we have to fear is fear itself. You entered: The only thing we have to fear is fear itself. (2) Complete the get_num_of_characters() function, which returns the number of characters in the user's string. We encourage you to use a for loop in this function. (2 pts) (3) Extend the program by calling the get_num_of_characters() function and then output the returned result. (1 pt) (4) Extend the program further by implementing the output_without_whitespace() function. output_without_whitespace() outputs the string's characters except for whitespace (spaces, tabs). Note: A tab is '\t'. Call the output_without_whitespace() function in main(). (2 pts)Ex: Enter a sentence or phrase: The only thing we have to fear is fear itself. You entered: The only thing we have to fear is fear itself. Number of characters: 46 String with no whitespace:…arrow_forwardNeed help with this while loop question: (Please do this in Python programming) Using while True loop that: Prompts the user to enter a word; may use one input statement in function Calculates the number of words entered with an upper case first letter Presses (hits) the Enter/Returns key on the keyboard, without typing anything to signal the end of the loop Once the loops end, the function should return (not print) one of the following messages: "0 words were entered" "Words with upper case first letter = x', where x is the number of words maybe 0 if no words entered had an upper case first letter The output needs to look like this: (see image attached)arrow_forward
- Q#1: Develop a program that inputs a number from the user using for loop. It display number if its greater than 0 otherwise inputs next number using continue statement.arrow_forward// This program illustrates the use of a sentinel in a while loop. // The user is asked for monthly rainfall totals until a sentinel// value of -1 is entered. Then the total rainfall is displayed.#include<iostream>using namespace std;int main(){// Fill in the code to define and initialize to 1 the variable monthfloat total = 0, rain;cout << "Enter the total rainfall for month "<< month << endl;cout << "Enter -1 when you are finished" << endl;// Fill in the code to read in the value for rain// Fill in the code to start a while loop that iterates// while rain does not equal -1{// Fill in the code to update total by adding it to rain cout << "Enter the total rainfall in inches for month "<< month << endl;cout << "Enter -1 when you are finished" << endl;// Fill in the code to read in the value for rain} // end of while loopif (month == 1)cout << "No data has been entered" <<endl;elsecout << "The total…arrow_forward19.1 LAB: Count multiples Write a program that takes three integers as input: low, high, and x. The program then outputs the number of multiples of x between low and high inclusive. Ex: If the input is: 1 10 2 the output is: 5 Hint: Use the % operator to determine if a number is a multiple of x. Use a for loop to test each number between low and high. The code I used doesn't work. Use Python to help me with this, please.arrow_forward
- program4_3.pyWrite a program that uses nested loops to print the output exactly as shown below. NOTE: You must use nested loops.arrow_forwardIf the output of the following for loop is 25 18 What are the loop continuation condition and increment? for(int count = 25;___________; ___________) cout << count << " ";arrow_forwardprogram using a while loop that lets the user enter a series of integers. The user should enter 10 values and the program will display the two largest numbers. You can only use a number once.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