Question

10. The following loop is supposed to sum all of the input values on file indata Wu wrong with it? Change the code so that it works correctly. sum = 0; indata >> number; while (indata) indata >> number; sum = sum + number;
0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
10. The following loop is supposed to sum all of the input values on file indata...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • What does the following nested loop structure output? count = 1; while (count <= 11) {innerCount...

    What does the following nested loop structure output? count = 1; while (count <= 11) {innerCount = 1 while (innerCount <= (12 - count)/2) {cout << " "; innerCount++;} innerCount = 1; while (innerCount = 1; while (innerCount <= count) {cout << "0"; innerCount++;} cout << endl; count++;} What does the following nested loop structure output? count = 1; while (count <= 10) {innerCount = 1; while (innerCount <= 10) {cout << setw(5) << count * innerCount; innerCount++;} cout <<...

  • Write pseudocode while loop to sum all the values between 2 integers (A & B, input...

    Write pseudocode while loop to sum all the values between 2 integers (A & B, input by the user), including A and B, and print the resulting sum. A must be less than B, otherwise print 0.

  • Write a program that prints the following console output using the while-loop and for-loop D not...

    Write a program that prints the following console output using the while-loop and for-loop D not use if-else, setw) and ciomanip> for this problem. .Before you open a Word file to copy the screen shots, tell Dr. Jo. Save the Word file as your name in your flash drive. .Take a screen-shot the code and paste to the Word file. (5 points). Take a screen-shots of the console output and paste to the Word file. (5 points) Save the Word...

  • Convert the following while loop into a for loop. int 1 - 50: int sum-07 while...

    Convert the following while loop into a for loop. int 1 - 50: int sum-07 while (sum < 1000) sum - sum + 1; Question 35 (2 points) Saved Given an int variable k that has already been declared, use a while loop to print a single line consisting of 80 dollar signs. Use no variables other than k. int sum = 0; for(int i = 100;sum < 10000;1-- sum = sum + i;

  • Write a for loop that assigns summed Value with the sum of all odd values from...

    Write a for loop that assigns summed Value with the sum of all odd values from 1 to user Num. Assume userNum is always greater than or equal to 1. Ex: If userNum is 5, then summed Value is 9 (i.e. 1+3+5 =9). Function Save C Reset MATLAB Documentation 1 function summedValue - Oddssum(userNum) summedValue = 0; % Write a for loop that assigns summedValue with the % sum of all odd values from 1 to user Num 7 end...

  • A. What is the output of the following C++ code fragment? (all variables are of type...

    A. What is the output of the following C++ code fragment? (all variables are of type int) int count-1; int y-100; while (count 3) y=y-1 ; count+t cout << y << endl; cout<< count <<endl What is the value of x after control leaves the following while loop? (all variables are of type int) B. int x0 while (x < 20) sum- sum+x cout << sum<< endl;

  • I am given an input file, P1input.txt and I have to write code to find the...

    I am given an input file, P1input.txt and I have to write code to find the min and max, as well as prime and perfect numbers from the input file. P1input.txt contains a hundred integers. Why doesn't my code compile properly to show me all the numbers? It just stops and displays usage: C:\> java Project1 P1input.txt 1 30 import java.io.*; // BufferedReader import java.util.*; // Scanner to read from a text file public class Project1 {    public static...

  • Use a loop to find the sum of all numbers between 0 and #mystery_int, including bounds...

    Use a loop to find the sum of all numbers between 0 and #mystery_int, including bounds (meaning that if #mystery_int = 7, you add 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7). However, there's a twist: mystery_int might be negative. #So, if mystery_int was -4, you would -4 + -3 + -2 + -1 + 0. Coding Problem 3.3.3 (External resource) 3.0 points possible) SumLoop.py 1 mystery_int -3 loop to find the sum...

  • You are provided with an input file called "sensor.txt" and a "code skeleton" of the exam questio...

    You are provided with an input file called "sensor.txt" and a "code skeleton" of the exam questions. The text file has 10 numbers. 1. You will scan the 10 values located in “sensor.txt” to an array of variable type double, using a loop of your choice. 2. You will create a user defined function that will take your array as an input and find the average value. (Ex. arr[] = {15, 12, 13, 10}, the sum will be 50 then...

  • 2. Consider the following recursive function (Chapter 17, #9, modified) void recFun (int x) { if...

    2. Consider the following recursive function (Chapter 17, #9, modified) void recFun (int x) { if (x > 10) { recFun (x / 10); cout<< X % 10; } else cout<< x; } a) What is printed by the call: recFun (268); b) How can the code be modified so that when a number is input, its digits are printed on separate lines? c) How can the code be modified so that the sum of all digits is printed?

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