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
Tyra used the software development life cycle to create a new game. After debugging and documenting code, she released it to her
REY [17]

Answer:

Maintenance

Explanation:

Maintenance

This primarily involves updating and making improvements based on user feedback, as well as resolving any defects that arise.

6 0
3 years ago
Assuming a 1-KB page size, what are the page numbers and offsets for the following address references (provided as decimal numbe
bagirrra123 [75]

<u>Answer:</u>

(a) page = 3; offset = 13

(b) page = 41; offset = 111

(c) page = 210; offset = 161

(d) page = 634; offset = 784

(e) page = 1953; offset = 129

8 0
2 years ago
: For each of the following words identify the bytethat is stored at lower memory address and the byte that is storedat higher m
Aloiza [94]

Answer:

In a <u>little endian computer</u> -The data's least substantial byte is put at the lower address byte. The remaining information will be put in memory in order in the next three bytes.

a)1234

4 is placed at the least significant bits,so this byte stored at lower memory address.

1 is placed at the most significant bits,so this byte stored at higher memory address.

b) ABFC

C is placed at the least significant bits,so this byte stored at lower memory address.

A is placed at the most significant bits,so this byte stored at higher memory address.

c) B100

0 is placed at the least significant bits,so this byte stored at lower memory address.

B is placed at the most significant bits,so this byte stored at higher memory address.

d) B800

0 is placed at the least significant bits,so this byte stored at lower memory address.

B is placed at the most significant bits,so this byte stored at higher memory address.

5 0
3 years ago
Which of the following would be the most appropriate way to define a method that calculates and returns the final price, after t
Oksanka [162]

D. I hope it helped
5 0
3 years ago
What should be done on a tablet in order for that tablet to cease all network connections?
ankoles [38]

Answer:

Turn On Airplane Mode

Explanation:

Turning off cellular does not turn off wifi.

Turning off wifi does not turn off cellular.

Turning off location services does not affect your network connections.

Airplane mode is what turns off all network connections.

3 0
3 years ago
Other questions:
  • . _______ are the components that allow a posi-traction differential to transfer power from one drive wheel to another.
    10·1 answer
  • A hub transmits all incoming messages to all of its ports except the port where the messages came in. A switch usually sends mes
    14·2 answers
  • Word Online works exact same as the downloaded Office 2016 version.<br>True<br>False​
    7·1 answer
  • In several languages, the visual development environment is known by the acronym ____.
    12·1 answer
  • Whenever Jim starts his laptop, he sees some commands and numbers appearing on his screen. These instructions are being processe
    12·2 answers
  • This is a wise and hard question.....What is the hardest question in the world? I know the answer do you?
    10·1 answer
  • Help to how to write pseudo code to insert a new node to Binary Search Tree. Using C++.
    15·1 answer
  • Choose all that apply.
    11·1 answer
  • What is a file path?
    7·1 answer
  • Define a function isPrime that consumes an integer argument and returns 1 if it'a prime number; 0 if it's not a prime number.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!