Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'m having an issue with one of the question on myProgrammingLab. Covering I/O

ID: 3853510 • Letter: I

Question

I'm having an issue with one of the question on myProgrammingLab. Covering I/O Streams. I will link the question and error my code generates. Rember, this is in myProgrammingLab, so it may be picky. Any help would be greatly appreciated. Thank you.

int num;
ifstream outFile;
outFile.open("numbers");
cin >> num;
outFile.close();

int a,sum=0;
for(int i=0; i<num; i++)
{
cin>> a;
sum = sum+a;
}
cout << sum << endl;

Given the availability of a file named numbers write the statements necessary to numbers and display their total

Explanation / Answer

    int num,sum=0,no;
    int>     //file
   ifstream outFile;
   outFile.open("numbers");//opening file
  

    if (!outFile.is_open()) return 0;
   cin >> num; //reading num
    string word;
    //reading file word by word
    while (num>0 && outFile >> word)
    {
  
       // object from the class stringstream
          >            for(i=0;i<word.length();i++){
              >            }

           sum=sum+onum;//adding sum
            num--;
    }
    cout<<sum;
   outFile.close();

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote