Note: Could you plz go through this code and let me
know if u need any changes in this.Thank You
=================================
inFile.txt (Input file):
42
468
335
501
170
725
479
359
963
465
706
146
282
828
962
492
996
943
828
437
392
605
903
154
293
383
422
717
719
896
448
727
772
539
870
913
668
300
36
895
704
812
323
334
674
665
142
712
254
869
548
645
663
758
38
860
724
742
530
779
317
36
191
843
289
107
41
943
265
649
447
806
891
730
371
351
7
102
394
549
630
624
85
955
757
841
967
377
932
309
945
440
627
324
538
539
119
83
930
542
834
116
640
659
705
931
978
307
674
387
22
746
925
73
271
830
778
574
98
513
987
291
162
637
356
768
656
575
32
53
351
151
942
725
967
431
108
192
8
338
458
288
754
384
946
910
210
759
222
589
423
947
507
31
414
169
901
592
763
656
411
360
625
538
549
484
596
42
603
351
292
837
375
21
597
22
349
200
669
485
282
735
54
1000
419
939
901
789
128
468
729
894
649
484
808
422
311
618
814
515
============================

===========================
#include <fstream>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <vector>
using namespace std;
void readFile(int &sum,int &cnt,double &avg,ifstream
&DataIn);
bool isFileAvailable(ifstream &DataIn);
int main() {
//Declaring variables
int cnt=0,sum=0;
double avg=0.0;
ifstream DataIn;
DataIn.open("inFile.txt");
bool b=isFileAvailable(DataIn);
if(b)
{
readFile(sum,cnt,avg,DataIn);
cout<<"No of Numbers in the file
:"<<cnt<<endl;
cout<<"Sum of Numbers in the file
:"<<sum<<endl;
cout<<"Average of Numbers :"<<avg<<endl;
}
else
{
cout<<"** File Not Found
**"<<endl;
}
return 0;
}
bool isFileAvailable(ifstream &DataIn)
{
//checking whether the file name is valid or not
if(DataIn.fail())
{
return 0;
}
else
{
return 1;
}
}
void readFile(int &sum,int &cnt,double &avg,ifstream
&DataIn)
{
int num;
//Reading the data from the file
while(DataIn>>num)
{
cnt++;
sum+=num;
}
DataIn.close();
avg=((double)sum)/cnt;
}
==========================================
Output:

=====================Could you plz rate me well.Thank You
C++ 3. Write a program that reads integers from a file, sums the values and calculates...
Consider the following program that reads a number of nonnegative integers into an array and prints the contents of the array. Complete the missing parts, add new function prototypes and function definitions, and test the program several times. Add the following to the program: Write a void function that prints the list of nonnegative integers in reverse. Write a void function that prints all the numbers stored in the list that are greater than 10. It will also print the...
Python DESCRIPTION Write a program that will read an array of integers from a file and do the following: ● Task 1: Revert the array in N/2 complexity time (i.e., number of steps) . ● Task 2: Find the maximum and minimum element of the array. INPUT OUTPUT Read the array of integers from a file named “ inputHW1.txt ”. To do this, you can use code snippet from the “ file.py ” file. This file is provided in Canvas....
a. Provide me with your code file, output file and the text file. 1. Create a file with a series of integers. Save it as numbers. txt. Write a program that reads all the numbers and calculates their sum . 2. Create a file having different integers than the first one. Save it as numbers1. txt . Write a program that reads all the number and calculates their average. Important: The two files that you are creating will contain different...
Write a program in C++ that reads in integer numbers from a file called scores.txt until the sentinel value -999 is read. The program should then output the total and average of the numbers read and output each of the numbers incremented by the overall average to a file called or scoresout.txt along with the sentinel value of -999 at the end So if 10, 20, 30 and -999 are read in then the program would display a total of...
C programming! Write a program that reads integers until 0 and prints the sum of values on odd positions minus the sum of values on even positions. Let ?1, ?2, … , ??, 0 be the input sequence. Then the program prints the value of ?1 − ?2 + ?3 − ?4 + ⋯ ??. The input is a sequence of integers that always contains at least 0 and the output will be a single number. For example, for input...
Write a program that will take input from a file of numbers of type double and output the average of the numbers in the file to the screen. Output the file name and average. Allow the user to process multiple files in one run. Part A use an array to hold the values read from the file modify your average function so that it receives an array as input parameter, averages values in an array and returns the average Part...
Write a program in C that reads 20 float numbers from a file. The values are stored in a vector (1-dimensional array). Find and display the smallest number, the second smallest number, and the third smallest number of the set. Use only these libraries: stdio.h, stdlib.h, math.h, and string.h. Below is an example of the input file (in1.txt) and the resulting output file (output.txt). In1.txt: 3.14 4.05 -3.73 4.13 1.32 -2.21 0.46 4.57 4.64 -3.42 4.57 -0.14 3.00 -3.58 -0.78...
Write a program that reads two integer values. It then calculates and displays the sum and average of all values between them, Le. if the first value is vi and the second value is 2, then the program calculates and displays the sum and average of all values in the closed range Iv1,2 Your Program must satisfy the following constraints: A. make sure that v1 is less than 2 B. Use a function named getStats(that takes two integer yalues as...
Write in C++ using emacs. Write a program that calculates the ending balance of several savings accounts. The program reads information about different customers’ accounts from an input file, “accounts.txt”. Each row in the file contains account information for one customer. This includes: the account number, account type (premium, choice, or basic account), starting balance, total amount deposited, and total amount withdrawn. Your program should: - open the file and check for successful open, - then calculate the ending balance...
Write a program in C that creates an array of 100 random numbers from 0-99. The program sums the random numbers and prints the sum. It then writes the numbers to a new file using open, close and write. Then looks in the current directory for files that match the pattern “numbers.XXXX”. For each file, open the file and read the file. You can assume that the file will contain 100 integers. Sum the integers. Print the filename and the sum...