Write a program( using only and ) that reads in a datafile of an unknown quantity of integers, and prints out the following information: The number of values in the dataset The maximum value The minimum value The average of the values
Note: Please only answer this if your using ONLY #include and #include . DO NOT USE ANY OTHERS! only using c++
#include <iostream> #include <fstream> using namespace std; int main() { char fileName[100]; cout << "Enter file name: "; cin >> fileName; ifstream in(fileName); if (in.is_open()) { int min = 0, max = 0, avg = 0, count = 0, num; while (in >> num) { if (count == 0) { min = num; max = num; } ++count; if (num > max) max = num; if (num < min) min = num; avg += num; } cout << "Minimum number is " << min << endl; cout << "Maximum number is " << max << endl; cout << "Count is " << count << endl; cout << "Average is " << avg/(double)count << endl; in.close(); } else { cout << fileName << " does not exists!" << endl; } return 0; }
Write a program( using only and ) that reads in a datafile of an unknown quantity...
Please do in C and only use stdio.h. Write a program that reads n integers into an array, then prints on a separate line the value of each distinct element along with the number of times it occurs. The values should be printed in ascending order. Turn in your code and input/result together. Suppose, for example, that you input the values -7 3 3 -7 5 5 3 as the elements of your array. Then your program should print -7...
Problem Definition Write a program called process_ages that reads in an array of up to 10 integers representing peoples ages in years and calculates and prints the maximum age and the minimum age and the average age. Your program should stop reading when either the 10th number is entered or the user enters -1. If the user enters any other negative number or a value above 150, they should be warned and prompted again for a valid age. You should...
(While-loop controlled by a sentinel value) Write a program that reads an unspecified number of integers. Your program ends with the input 0. Determine and display how many positive and negative values have been read, the maximum and minimum values, and the total and average of the input values (not counting the final 0).
C++ 3. Write a program that reads integers from a file, sums the values and calculates the average. a. Write a value-returning function that opens an input file named in File txt. You may "hard-code" the file name, i.e., you do not need to ask the user for the file name. The function should check the file state of the input file and return a value indicating success or failure. Main should check the returned value and if the file...
JAVA. Write a program that reads in a series of positive integers and prints out the maximum value entered. The user will indicate they are finished entering numbers by entering zero or a negative integer.
Our store sells everthing for $10 over cost. Write a program will reads in the amount we pay for an item and prints out the cost and the amount we should sell it for. You may assume all the prices and integers. Your program should work for any number of lines of data. please no complicated solutions program must be able to work correctly.
Write a program that reads k integers and displays their sum. Write a program that reads k values representing family income from the keyboard and place them into the array. Find the maximum income among these values. Count the families that make less than 10 percent of the maximum income. (JAVA)
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...
Task 1 : Write a Java program that prompts for and reads 10 integers from the user into an integer array of size 10, it then: - calculates the sum and average of positive numbers of the array and displays them. [Note: consider 0 as positive] Note: The program must display the message: "There are no positive values" if the array does not contain any positive value.
Write a program that reads an unknown number (but no more than 100) of integer values from a file (“ass5_Q4_input.txt”), and displays distinct numbers. (i.e. if a number appears multiple times, it is displayed only once.)