Question

4) (12 points) Write the CH code that continuously (use a loop) prompts a user to input a floating point number. Each time, t

0 0
Add a comment Improve this question Transcribed image text
Answer #1

/*
 * C++ Program
 */

#include <iostream>
using namespace std;

int main()
{
  float num, sum = 0;
  int i = 1;

  while (sum <= 100)
  {
    cout << "input " << i << ": ";
    cin >> num;
    sum += num;
    i++;
  }
  
  return 0;
}

@imtusharsharma/ProductiveSaddlebrownMigrat... No description invite 8+ run share + new repl my repls 28 talk n imtusharshar.

Add a comment
Know the answer?
Add Answer to:
4) (12 points) Write the CH code that continuously (use a loop) prompts a user to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • (java) Write a While loop that prompts the user for only even numbers. Keep prompting the...

    (java) Write a While loop that prompts the user for only even numbers. Keep prompting the user to enter even numbers until the user enters an odd number. After the loop ends, print the sum of the numbers. Do not include that last odd number. You should not store the numbers in an array, just keep track of the sum. Make sure to use a break statement in your code. You may assume that a java.util.Scanner object named input has...

  • Prepare pseudocode for a program that lets a user continuously enter numbers until the number 99...

    Prepare pseudocode for a program that lets a user continuously enter numbers until the number 99 is entered. Once the user has stopped entering numbers, display the number of numbers entered AND the sum of those numbers. You'll need a counter and an accumulator for this (see pp. 179-181 and 205-208). Make sure your loop is structured (see priming input in figure 3-16). Don't forget to comment your code. Don't forget to display appropriate prompts when requesting input from the...

  • Write a program which: - prompts the user for 2 numerical inputs - stores their two...

    Write a program which: - prompts the user for 2 numerical inputs - stores their two inputs in variables as floats - Use a while in loop to ask a user for a valid operation: (if the user's input operation isn't one of those listed above, instead print a message telling them so, and continue asking for the valid operation) - prompts the user for an arithmetic operation ( + - * / %) - stores the user's input as...

  • Write a C program named space_to_line.c that features a while loop that continuously reads input from...

    Write a C program named space_to_line.c that features a while loop that continuously reads input from the user one character at a time and then prints that character out. The exception is that if the user inputs a space character (‘ ‘), then a newline character (‘\n’) should be printed instead. This will format the output such that every word the user inputs is on its own line. Other than changing the spaces to newlines, the output should exactly match...

  • Write a code segment that prompts the user to enter a double number between (5.55 and...

    Write a code segment that prompts the user to enter a double number between (5.55 and 123.3) inclusive. If the input is invalid, print an error message and loop until the input is valid. Code in c++

  • Write a program that will loop ten times. In each iteration prompt user to enter an...

    Write a program that will loop ten times. In each iteration prompt user to enter an integer between -50&50. Print the input, keep a running sum of the inputs, and track the minimun and maximum numbers input. After the loop is complete, minimum number entered, maximum number entered, sum of all numberes entered, and average of all numbers entered. Format all output. Before running the loop, print the label "Input values: ". Within the loop, print value entered by user...

  • Q1 (2 pts) Shopping list Write a program that prompts a user for items on their...

    Q1 (2 pts) Shopping list Write a program that prompts a user for items on their shopping list and keeps prompting the user until they enter "Done" (make sure your program can stop even if the user enters "Done" with different cases, like "done"), then prints out the items in the list, line by line, and prints the total number of items on the shopping list. Output (after collecting items in the while loop) should look something like this: Apple...

  • C++ Write a program that prompts the user to enter integers or a sentinel to stop....

    C++ Write a program that prompts the user to enter integers or a sentinel to stop. The program prints the highest and lowest numbers entered, the sum and the average. DO NOT USE ARRAYS, only variables and loops. Write a program the prompts the user to input a positive integer. Keep asking the user until a positive integer is entered. Once a positive integer is entered, print a message if the integer is prime or not. (NOTE: A number is...

  • 1. Prepare C++ code that prompts the user for an input integer n, creates a vector...

    1. Prepare C++ code that prompts the user for an input integer n, creates a vector consisting of numbers 0,1,2,…,n-1, runs the STL algorithm random_shuffle on it and then prints out the resulting outcome, i.e. the resulting random permutation. 2. Prepare C++ code that prompts the user for an input integer n, creates a vector consisting of numbers 0,1,2,…,n-1, runs the STL algorithm random_shuffle on it and creates three copies of the resulting outcome (probably 3 .txt files).

  • Write a loop statement that prompts the user to guess a secret number. Set the secret...

    Write a loop statement that prompts the user to guess a secret number. Set the secret number before the loop. Continue executing until the user correctly guesses the secret number. If they come within 10 numbers either above or below tell the user they are getting warmer. If they are outside of 10 numbers tell them they are getting colder.(Python)

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT