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]
3 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]3 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
Question 4: What will be the output of the code? Show a complete analysis.
Eva8 [605]

Answer:

The output of the code is 8

4 0
3 years ago
Car batteries have two terminals which are (blank).
Bumek [7]

Answer:

a positive and negative

3 0
3 years ago
Read 2 more answers
Assume that sentence is a variable that has been associated with a string consisting of words separated by single space characte
sleet_krkn [62]

The right code is,

secondWord = sentence.substr (sentence.find ("`") + 1);

secondWord = secondWord.substr (0, secondWord.find ("`"));

3 0
3 years ago
Read 2 more answers
PLEASE ANSWER LAST DAY OF SCHOOL. Discussion Topic
meriva

Answer:

You can't really say it matters whether it's short or long

Explanation:

There several coding language some short and some long with different purposes so it doesn't really make a difference

Although some coders have been able to shorten some codes so I'd say shorter is faster and be[er and easier to memorize

Thanks hope I was helpful

4 0
2 years ago
Positive thinkers tend to
andreev551 [17]

Answer:

I would say D hope this helps

3 0
3 years ago
Read 2 more answers
Other questions:
  • You can write as many constructors for a class as you want, as long as they all have different ____ lists.
    8·1 answer
  • Which of the following instruments are used when performing a high-rate discharge test on a storage battery
    7·1 answer
  • A(n) ____ instruction might look like a meaningless string of 0s and 1s, but it actually represents specific operations and stor
    9·1 answer
  • ________ is a remote access client/server protocol that provides authentication and authorization capabilities to users who are
    10·1 answer
  • When performing actions between your computer and one that is infected with a virus, which of the following offers NO risk of yo
    11·2 answers
  • When developing e-business systems, an in-house solution usually requires a ____ for a company that must adapt quickly in a dyna
    11·1 answer
  • A chemical mixture that is burned to produce thrust. (Jet engine homework)
    14·2 answers
  • When machining rotors, what is the reason for setting the indexing collars to zero?
    9·1 answer
  • A _____ is a computer that is deliberately set up to be easily hacked into.
    10·1 answer
  • How are computers classified into different types? Explain ​
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!