Question

In the main(), below, write a program that prompts for (1) how many values to sum,...

In the main(), below, write a program that prompts for (1) how many values to sum, and then (2) uses a summing loop to prompt for and add up 5 numbers.

#include <iostream>

#include <iomanip>

using namespace std;

int main()

{

    < your answer goes here>

return 0;

}

Homework Answers

Answer #1
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
    int size, sum = 0, num;
    cout << "How many values to sum? ";
    cin >> size;
    cout << "Enter " << size << " integers: ";
    for (int i = 0; i < size; ++i) {
        cin >> num;
        sum += num;
    }
    cout << "Sum of entered numbers is " << sum << endl;
    return 0;
}

Know the answer?
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
Similar Questions
In C++ Please, In the main(), below, write a program that prompts for (1) how many...
In C++ Please, In the main(), below, write a program that prompts for (1) how many values to sum, and then (2) uses a summing loop to prompt for and add up 5 numbers. #include <iostream> #include <iomanip> using namespace std; int main() { < your answer goes here> return 0; }
In C++ Please, Write a program that (1) prompts for two integers, (2) prints out their...
In C++ Please, Write a program that (1) prompts for two integers, (2) prints out their sum, (3) prints out the first divided by the second, and (4) prints out the natural log of the first number raised to the power of the second number. #include <iostream> #include <iomanip> using namespace std; int main() { <your answer goes here> return 0; }
In C++ Please, In the main(), below, write a program that uses a switch-statement to choose...
In C++ Please, In the main(), below, write a program that uses a switch-statement to choose between three numbers. The number, choice, should be prompted for and each choice should print out a unique statement. Also, the prompt should continue indefinitely (i.e. keep prompting until the user force-quits the program), and there should be a general catch-all if the user enters other than the three possible choices. #include <iostream> #include <iomanip> using namespace std; int main() { <your answer goes...
Please provide answer in the format that I provided, thank you Write a program that prompts...
Please provide answer in the format that I provided, thank you Write a program that prompts the user to input a string. The program then uses the function substr to remove all the vowels from the string. For example, if str=”There”, then after removing all the vowels, str=”Thr”. After removing all the vowels, output the string. Your program must contain a function to remove all the vowels and a function to determine whether a character is a vowel. You must...
Using a for Loop visual c++ Summary In this lab the completed program should print the...
Using a for Loop visual c++ Summary In this lab the completed program should print the numbers 0 through 10, along with their values multiplied by 2 and by 10. You should accomplish this using a for loop instead of a counter-controlled while loop. Instructions Write a for loop that uses the loop control variable to take on the values 0 through 10. In the body of the loop, multiply the value of the loop control variable by 2 and...
Instructions Write a program that produces the following output: CCCCCCCCC ++ ++ CC ++ ++ CC...
Instructions Write a program that produces the following output: CCCCCCCCC ++ ++ CC ++ ++ CC ++++++++++++++ +++++++++++++++ CC ++++++++++++++ +++++++++++++++ CC ++ ++ CCCCCCCCC ++ ++ Note: The letter C in the output must be uppercase. #include <iostream> using namespace std; int main() {   cout<<"CCCCCCCCC ++ ++ CC ++ ++ CC ++++++++++++++ +++++++++++++++ CC +++++++++++++\n";   cout<<"+++++++++++++++ CC ++ ++ CCCCCCCCC ++ ++";   return 0; } this is my woek #include <iostream> using namespace std; int main() { cout<<"CCCCCCCCC ++...
Please write variables and program plan (pseudocode) of the C++ programming below: #include <iostream> #include <cmath>...
Please write variables and program plan (pseudocode) of the C++ programming below: #include <iostream> #include <cmath> using namespace std; void divisors(int num); int main () {    char repeat;    int num;       while (repeat !='n')    {        cout << "Enter a number: ";        cin >> num;        divisors(num);        cout << "Continue? (y or n): ";        cin >> repeat;    }    return 0; } void divisors(int num) {   ...
How to trace a c++ program by hand #include<iostream> using namespace std;    class Test {...
How to trace a c++ program by hand #include<iostream> using namespace std;    class Test {     int value; public:     Test(int v); };    Test::Test(int v) {     value = v; }    int main() {     Test t[100];     return 0; } _______________ #include <iostream> using namespace std; int main() { int i,j; for (i=1; i<=3; i++) { for(j=1; j<=i; j++ ) { cout<<"*"; } cout << "\n";   } return 0; }
Write a while loop that prints userNum divided by 2 (integer division) until reaching 1. Follow...
Write a while loop that prints userNum divided by 2 (integer division) until reaching 1. Follow each number by a space. Example output for userNum = 40: 20 10 5 2 1 ..... my code: #include <iostream> using namespace std; int main() { int userNum; userNum = 40; /* Your solution goes here */ while (userNum != 1){ userNum = userNum/2; cout << userNum << " ";   } cout << endl; return 0; } ........ but as a result i...
6.25.1: Unit testing C++ Add two more statements to main() to test inputs 3 and -1....
6.25.1: Unit testing C++ Add two more statements to main() to test inputs 3 and -1. Use print statements similar to the existing one (don't use assert). #include <iostream> using namespace std; // Function returns origNum cubed int CubeNum(int origNum) { return origNum * origNum * origNum; } int main() { cout << "Testing started" << endl; cout << "2, expecting 8, got: " << CubeNum(2) << endl; /* Your solution goes here */ cout << "Testing completed" << endl;...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT