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
Computers process information consistently for all transactions. This creates a risk that:______
Anna007 [38]

Answer:

b. erroneous processing can result in the accumulation of a great number of misstatements in a short period of time.

Explanation:

Because of the consistent nature of processing in computers, this is capable of creating certain kinds of risk. From the option, one of the probable risk that can result from consistent information processing for multiple transactions at the same time is erroneous processing. This can therefore lead to a pile of misstatements in only a short period of time.

6 0
3 years ago
The basic form of backup used in magnetic tape operations is called
Harrizon [31]
Answer is the son-father-grandfather concept. Good luck
5 0
3 years ago
The ________ of a cpu dictates how many instructions the cpu can process each second.
makkiz [27]
Gigahertz is the correct answer I believe.
My processor is a i5-6600k with 3.5ghz so assuming GHz is the speed I believe it would be gigahertz
3 0
3 years ago
Jamie is using the UNIX file system to work on his computer. He puts a dot before the file extension to separate it from the fil
klio [65]

Answer: as a file extension

Explanation:

4 0
3 years ago
Read 2 more answers
Bill is building a project network that involves testing a prototype. he must design the prototype (activity 1), build the proto
Vedmedyk [2.9K]

Answer:

Bill is building a project network that involves testing a prototype. he must design the prototype (activity 1), build the prototype (activity 2), and test the prototype (activity 3). activity 1 is the predecessor for activity 2 and activity 2 is the predecessor for activity 3. if the prototype fails testing, bill must redesign the prototype; therefore, activity 3 is a predecessor for activity 1. this is an example of

b. looping

Explanation:

  • The given example is of looping because each activity is leading to another activity on the completion of some conditions.
  • The answer a is not valid as it is not just an example of conditional statements rather it is a loop which will keep moving until unless reached a situation to end it.
  • The option c, d an e are not right options for the given example.
4 0
3 years ago
Other questions:
  • Write a complete C++ program that do following. Read a positive integer from the user with proper prompt. Assume that this user
    9·1 answer
  • Which of the following button should always be included when designing a navigation pictures escape contact FAQ
    5·2 answers
  • Which part of a computer takes the text and pictures on your screen and prints them onto paper?
    6·1 answer
  • What type of function is being performed when a router screens packets based on information in the packet header
    8·1 answer
  • Given an char variable last that has been initialized to a lowercase letter, write a loop that displays all possible combination
    8·1 answer
  • Write a program num2rome.cpp that converts a positive integer into the Roman number system. The Roman number system has digits I
    8·1 answer
  • Why do meteorologists use data such as temperature, wind speed, and air
    9·1 answer
  • The memory used by the CPU to temporarily hold data while processing is called _______. random access memory central processing
    5·1 answer
  • Another term for the plot structure of the hero journey
    13·1 answer
  • What is a program that includes a function parameter capable of doing?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!