Question
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
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:
Here's my outfile:
My answer is that large number "1717986916"... but it should be 3. Why is my answer that large number?
nfile Notepad File Edit FormatStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started