1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
andrey2020 [161]
3 years ago
7

Write a program sum.cpp that reads a sequence of integers from cin, and reports their sum. Example If you have a file numbers.tx

t that contains:
Computers and Technology
1 answer:
Katarina [22]3 years ago
8 0

Answer:

The solution code is as follows:

  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. using namespace std;
  5. int main()
  6. {
  7.    ifstream data;
  8.    float number;
  9.    float sum = 0;
  10.    
  11.    data.open("numbers.txt");
  12.    
  13.    while (data >> number) {
  14.        sum = sum + number;
  15.    }
  16.    cout<<sum;
  17.    return 0;
  18. }

Explanation:

Firstly, we create a ifstream object, <em>data</em> (Line 9). Then we can use the ifstream object to open the "numbers.txt" (Line 13) and use while loop to traverse through the number in the text file line by line (Line 15). White the loop is ongoing the number in each line is read by >> operator in a similar way to cin and then add each read number to sum variable (Line 16).

At last, display the output (Line 18).

You might be interested in
There are information that are in the web view source that may not appear on the web page such as meta name. In addition there c
SCORPION-xisa [38]

Answer:

True on a web page such meta name will not appear in web view source and irrelevant information will be displayed.

Explanation:

Basically web page source is compiled version of HTML script so the end-user he or she tries to view pages system will show only in HTML.

so meta name information and active object information will not be displayed while viewing the web source code instead of that the irrelevant informant ions will be displayed and end-user cannot under anything out of the web source code.

Moreover, even the client side validation script also will not be displayed.

Only HTML will be displayed  

3 0
3 years ago
Which type of password provides the highest level of permissions in bios?
OLEGan [10]
<span>Which type of password provides the highest level of permissions in bios? = Supervisor provides the highest level of permissions in the BIOS</span>
6 0
3 years ago
The chart shows an example of a study-time survey. Students can use the formula shown in the survey to figure out ways to track
LUCKY_DIMON [66]
<span>how many hours they can work on a project.</span>
3 0
3 years ago
Select the correct answer.
zmey [24]

the answer should be the letter a

3 0
3 years ago
Read 2 more answers
Compose an e-mail to your coworker Adam that describes how to add a photograph to a slide.
pantera1 [17]

The ways to add a photograph to a slide is given below: What to write when composing the email is also given below.

<h3>How do you Insert photos into a slide?</h3>

The steps are given below?\

  • The first thing to do is to open  the slide you want to insert the image on.
  • then click on Insert menu, and take the cursor to the Picture, and then one can click Photo Browser or insert pictures.
  • Then select the picture that you want and and one can drag it onto the slide.

Note that it is essential to follow the steps and one can add as many pictures as they want to their slides.

Learn more about e-mail from

brainly.com/question/24506250

#SPJ1

3 0
2 years ago
Other questions:
  • considering that two variables counters and accumulators are important in loop design. What would be their purpose?
    9·1 answer
  • What is the lucky 3 digit today
    12·1 answer
  • Write a SELECT statement that joins the Categories table to the Products table and returns these columns: category_name, product
    5·1 answer
  • Which one of these variables has an illegal name?
    11·1 answer
  • What safety feature melts to protect a circuit? a. fuse b. diode c. three-prong plug d. transistor
    10·2 answers
  • ............................... ?
    11·1 answer
  • The term integration mean?
    7·2 answers
  • Tradegy deals with _____
    14·1 answer
  • I.d 9934607467<br> p.a.s.s 54321<br><br> P.L.E.A.S.E J.O.I.N. Z.O.0.M. M.E.E.T.I.N.G
    10·1 answer
  • Html is a markup language that lets you identify common sections of a web page
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!