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
Write a class Example() such that it has a method that gives the difference between the size of strings when the '-' (subtractio
Mariulka [41]

Answer:

class Example:

def __init__(self, val):

self.val = val

def __gt__(self, other):

return self.val > other.val

def __sub__(self,other):

return abs(len(self.val) - len(other.val))

def main():

obj1 = Example('this is a string')

obj2 = Example('this is another one')

print(obj1 > obj2)

print(obj1 - obj2)

main()

\color{red}\underline{Output:}

3 0
2 years ago
Hjnjjjhhbbfg66ui998876dch
GalinKa [24]
What is your question? I’ll try my best to help
4 0
3 years ago
7. Question
Zigmanuir [339]
All server side errors start with 5XX
8 0
3 years ago
Where are you jaymann ive been looking for you
LuckyWell [14K]

Answer:

Explanation:

[[^hewoo I’m not em but thx for points

4 0
2 years ago
Read 2 more answers
Which statement best describes the Tell Me feature in PowerPoint 2016?
Bumek [7]

A statement best describes the Tell Me feature in PowerPoint 2016 is that: D. it opens a search field that can be used to look up old versions of presentations.

<h3>What is PowerPoint 2016?</h3>

PowerPoint 2016 refers to a software application that was designed and developed by Microsoft Inc., so as to avail its end users the ability to create various slides which can be used during a presentation.

In PowerPoint 2016, the Tell Me feature is a tool which opens a search field that can be used by end users to look up or search old versions of presentations.

Read more on PowerPoint here: brainly.com/question/26404012

#SPJ1

6 0
1 year ago
Other questions:
  • Julio is the department head for his company's customer service department. His staff has complained that they spend countless h
    13·2 answers
  • All tif files start at offset 0 with what 6 hexadecimal characters?​
    11·1 answer
  • Television, radio, newspapers, magazines, the Internet, and other forms of communication are collectively referred to as thea. W
    15·1 answer
  • The length property of the String object returns
    15·1 answer
  • Is Missouri a free state or a slave state​
    13·2 answers
  • Effective scrum masters apply which coaching behavior
    5·1 answer
  • What is the web page path on the web server for the URL:
    12·1 answer
  • What are the 5 font/typography families
    14·1 answer
  • Which of the following is not the disadvantage of closed
    7·2 answers
  • Which of the following is NOT one of the four benefits of using email?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!