1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
levacccp [35]
2 years ago
12

This program will read integers from a file and find results from these integers. Open the file, test to make sure the file open

ed. Use a loop to read the integers and process each integer as it is read. When End Of File is reached, close the file. After all of the integers have been read and processed, print the results for the following output: The integer count: The sum of the integers: The smallest integer: The largest integer: The average of the integers: Use notepad, vim, or other simple text editor to create a file named file1.txt containing the following, with one integer per line. Test the program two times. Use the following data in the first test: 11 9 18 22 27 33 21 For the second test add an additional line containing the number 40.
Computers and Technology
1 answer:
erma4kov [3.2K]2 years ago
4 0

Answer:

this is in cpp

#include <bits/stdc++.h>

#include<fstream>

using namespace std;

int main()

{

ifstream myfile;

myfile.open ("file1.txt");

// Check if file is opened

if (!myfile.is_open())

{

cout<<"Error: File could not be opened"<<endl;

}

else{

// variable to stor count,sum, minimum and maximum

int ct=0,sm=0,mn=INT_MAX,mx=INT_MIN;

// variable for taking input

int x;

// reading and processing in loop until there are more integers

while(myfile>>x){

ct++;

sm+=x;

mn= min(mn,x);

mx=max(mx,x);

}

// close the file when End of file is reached

myfile.close();

//printing results

cout<<"The integer count: "<<ct<<endl;

cout<<"The sum of the integers: "<<sm<<endl;

cout<<"The smallest integer: "<<mn<<endl;

cout<<"The largest integer: "<<mx<<endl;

cout<<"The average of the integers: "<<((sm*1.0)/ct)<<endl;

}

return 0;

}

Explanation:

You might be interested in
Someone please help fast! I’m taking the test rn and I don’t understand this!!!!!!
andrezito [222]

Answer:

the mistake that was made by allen is that he was not suppose to hire a highly proficient technician to install the heating and cooling system in the granary.

7 0
2 years ago
What is renewable energy
Marat540 [252]
Renewable energy is energy that is collected from renewable resources, which are naturally replenished on a human timescale, such as sunlight, wind, rain, tides, waves, and geothermal heat.
8 0
3 years ago
Eli needs to export files from his mailbox into a single file that is portable and can be backed up to removable media. Which fi
slava [35]

Answer:

PST

Resource:

This question has already been answered here: brainly.com/question/18415952

Explanation:

PST is the personal storage table, which is a file built by Microsoft to store data from outlook and other services too.  Really quick, this may or may not be an option that you are looking for but, what I would do in my opinion would be to use the PST and export it on a removable USB, since USBs are removeable media.

6 0
2 years ago
Word processing software allows users to do which of the following: format text design pages share documents mail merge document
Sergio039 [100]
Well most word processing softwares allow you to do many things to a document, if you use google documents or microsoft word i'm pretty sure you can do all of those things
5 0
3 years ago
Read 2 more answers
Some machine/items/gadget having only hardware​
shepuryov [24]
Yeh it’s becoz they work with hardware that’s why
6 0
3 years ago
Other questions:
  • What does the Sort feature do with a database
    13·1 answer
  • By applying styles formats are being applied ?
    14·2 answers
  • In what areas is leslie's underspending hurting her
    10·1 answer
  • The person in charge of recording the sound should always
    15·1 answer
  • How many dog breed are there
    9·2 answers
  • Jason works for a restaurant that serves only organic, local produce. What
    15·2 answers
  • Help please i will mark brainlist!
    7·1 answer
  • What's the difference between a robot and a machine?
    7·1 answer
  • 45 points!!
    15·2 answers
  • Discuss the advantages of using analogue multi-tester or digital multi-tester over the other.​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!