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
How does the occupational outlook affect the monetary benefits of a career
Ksivusya [100]
If there are changes to the responsibilities in a career, the typical outcome will change.
4 0
2 years ago
When a program is adapted to run on multiple processors in a multiprocessor system, the execution time on each processor is comp
____ [38]
I only need points for my questions
4 0
2 years ago
How do new sources of power assist in the development of inventions?
pentagon [3]
<span>New sources of power assist in the development of inventions since t</span>he new inventions would have been worthless without a reliable source of power energy.
3 0
3 years ago
What is the shortcut key to apply /remove the subscript effect?<br> Ctrl+=<br><br> Ctrl-+
telo118 [61]

Answer:

Press "Ctrl, "Shift" and "=" on your keyboard to turn off superscript formatting.

5 0
2 years ago
We introduced Sudoku as a CSP to be solved by search over
klemol [59]

Answer:

It can be a really good approach to use a local solver using the min conflicts heuristic in solving sudoku problems. It will work better actually. In this process, the value chosen is the value with the minimum conflicts. This is the general way a normal person would also tackle this problem. By this approach, if we keep taking the values with minimum conflicts the sudoku puzzle can be solved with a better performance.

Explanation:

8 0
2 years ago
Other questions:
  • What are paragraphs separated by
    9·1 answer
  • What is the 16-bit hexadecimal representation of each of the following signed decimal integers?
    13·1 answer
  • In one to two sentences, explain why citizens pay taxes
    8·1 answer
  • How do you think computers have helped to improve documentation, support and services within the healthcare industry.
    5·2 answers
  • Hey, how is everyone????????????????????????????????
    8·2 answers
  • The remove() method in the Queue interface ________. Group of answer choices retrieves, but does not remove, the head of this qu
    14·1 answer
  • List five applications field of a computer?​
    8·1 answer
  • How would you design an adaptive environment for people who are blind?
    10·1 answer
  • How to create drop down list in excel with multiple selections.
    13·2 answers
  • A word or phrase to help identify a file when you do not know the file name during the file expiration search
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!