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;
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();
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.