Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++, please. I will upvote Thank you! only edit from line 8 Lines 1-7 and lines 9- 19 cannot be changed. This program is

image text in transcribed

image text in transcribed

image text in transcribed

In C++, please. I will upvote Thank you! only edit from line 8

Lines 1-7 and lines 9- 19 cannot be changed.

This program is supposed to read from an input file and compute the total of the numbers it contains, writing the total to its output file. Fix it so that it works correctly. \( \begin{aligned} 1 & \text { \#include iostream> } \\ 2 & \text { \#include } \\ 3 & \text { using namespace std; } \\ 4 & \\ 5 & \text { int main() } \\ 6 & \{ \\ 7 & \text { ifstream in_file; } \\ 8 & \text { ifstream out_file; } \\ 9 & \\ 10 & \text { in_file.open("input.txt"); } \\ 11 & \text { int total }=0 ; \\ 12 & \text { int } n ; \\ 13 & \text { while (in_file }>>n)\{\text { total }=\text { total }+\mathrm{n} ;\} \\ 14 & \\ 15 & \text { out_file.open("output.txt"); } \\ 16 & \text { out_file }\langle19} return 0; buggy.cpp input.txt 121242

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions