#include <iostream> #include <fstream> using namespace std; int main() { int num
ID: 3615489 • Letter: #
Question
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
int num, sum = 0, i = 0;
ifstream infile;
infile.open ("infile-5-B-2.txt");
cout << “ Please enter any number ofintegers from the Standard Input (Keyboard) until the User inputsan x” << endl;
cout << "Reading data from file"infile-5-B-2.txt"" << endl << endl;
infile >> num;
while (infile)
{
cout << num << " ";
sum = sum + num;
i++;
infile >> num;
}
cout << endl << "Sum ofintegers " << sum << endl;
cout << "Number of integers "<< i << endl ;
if (i != 0)
cout <<"Average of integers " << (double)sum / i << endl ;
cout << endl ;
infile.close();
system("PAUSE");
return 0;
}
Explanation / Answer
please rate - thanks // EOF controlled for loop structure // The program will accept any number of integers from the StandardInput (Keyboard) until the User inputs an "CTRL Z". // then output the sum of the integers, the number of integers input,and the average of the integers. #include #include using namespace std; int main() { int num, sum = 0, i = 0; coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.