Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Program Help: This program reads in 3 numbers from the file infile.txt, sums the numbers, and writes the sum to the file outfile.txt. Here's

C++ Program Help: This program reads in 3 numbers from the file "infile.txt", sums the numbers, and writes the sum to the file "outfile.txt".

Here's my source code:

#include #include //must include this header file for streams

using namespace std;

int main() { ifstream in_stream; ofstream out_stream;

//open the files in_stream.open("infile.txt"); out_stream.open("outfile.txt");

int first, second, third;

in_stream >> first >> second >> third;

//display the sum of the first 3 numbers out_stream

return 0; }

Here's my infile: image text in transcribed

Here's my outfile: image text in transcribed

My answer is that large number "1717986916"... but it should be 3. Why is my answer that large number?

nfile Notepad File Edit Format

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

9th Edition

B01JXPZ7AK, 9780805360479

More Books

Students also viewed these Databases questions