Question

I am using programming language of DEV C++, and here is my assignment. Write a program,...

I am using programming language of DEV C++, and here is my assignment.

Write a program, maxmin.c to find the maximum and minimum of values in the file maxminin.txt.

Your output should look like:

There are 6 values in the file

The maximum value is 9.500000

The minimum value is 1.100000

and this is maxminin.txt:

8.2
1.1
3.7
2.2
9.5
4.3
0 0
Add a comment Improve this question Transcribed image text
Answer #1

MaxMin.cpp

#include <iostream>
#include<fstream>
#include<cfloat>
using namespace std;

int main()
{
ifstream inputFile;
inputFile.open("maxminin.txt");
double max = DBL_MIN, min =DBL_MAX;
int numbersCount = 0;
double eachValue = 0;
if (inputFile.is_open()) {
while (!inputFile.eof()) {
numbersCount++;


inputFile >> eachValue;
if(max < eachValue){
max = eachValue;
}
if(min > eachValue){
min = eachValue;
}


}
}
cout<<"There are "<<numbersCount<<" values in the file"<<endl;
cout<<"The maximum value is "<<max<<endl;
cout<<"The minimum value is "<<min<<endl;
inputFile.close();

return 0;
}

Output:

sh-4.3$ g++ -std-c++11 -o main*.cpp sh-4.3$ main There are 6 values in the file The maximum value is 9.5 The minimum value is

Add a comment
Know the answer?
Add Answer to:
I am using programming language of DEV C++, and here is my assignment. Write a program,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • using python programming language write a program that will manipulate the below excel record to the...

    using python programming language write a program that will manipulate the below excel record to the output provided This is what the output should look like Name Path ID Python-Excel C:\Users Desktop Python-Excell, C:Users IDesktop|Python-Excel2 PE12370, P009872,CD12890,U199912

  • Using Java programming language Your assignment is to implement a recursive reverse sorting algorithm. It should...

    Using Java programming language Your assignment is to implement a recursive reverse sorting algorithm. It should meet the following requirements: 1. The program shall graphically prompt the user for a file. 2. The program shall read the selected file which will contain 1 integer per line. 3. The program shall sort the values it reads from the file from largest to smallest. 4. The program shall write the values to an output file from largest to smallest in the same...

  • This assignment should be relatively easy. Write a program in C language, that reads in numbers...

    This assignment should be relatively easy. Write a program in C language, that reads in numbers from any file, one per line, until it detects that a 0 (zero not an oh') has been entered The 0 does not count as part of the number series. After all numbers have been entered print out the number of items entered, the sum, the minimum value entered, the maximum value entered, and the arithmetic mean (one on each line), in the order...

  • I am having a hard time with my program to assignment 4.12. Here are the instructions:...

    I am having a hard time with my program to assignment 4.12. Here are the instructions: The Payroll Department keeps a list of employee information for each pay period in a text file. The format of each line of the file is the following: <last name> <hours worked> <hourly wage> Write a program that inputs a filename from the user and prints to the terminal a report of the wages paid to the employees for the given period. The report...

  • C programming language 1. Write a program that prints the minimum value and the maximum value...

    C programming language 1. Write a program that prints the minimum value and the maximum value of a given array. For example array a is: int al 10] 140,30,20,50,10,80,99.90,85,70;: the minimum value is 10 and the maximum value is 99. Write a program that Converts an Integer from base 10 to base 2. 2. 3. Write a program that reads in ten marks and then calculates the pass rate

  • Answer should be in C programming language Write a program that will create an array of...

    Answer should be in C programming language Write a program that will create an array of 10 floating point numbers and take input 10 floats from keyboard. The program will print the position (index) of the maximum and minimum number among them

  • I need the programming to be in language C. I am using a program called Zybook...

    I need the programming to be in language C. I am using a program called Zybook Prompt: Write a statement that outputs variable numObjects. End with a newline. Given: #include <stdio.h> int main(void) { int numObjects; scanf("%d", &numObjects); return 0; } What I did so far. I am not sure if its right tho? #include <stdio.h> int main(void) { int numObjects; scanf("%d", &numObjects); printf(" num Objects is "); printf("%d\n", userAge); return 0; }

  • Dear Helpers, this is my final project for programming in C. I am not a programmer...

    Dear Helpers, this is my final project for programming in C. I am not a programmer but need to pass this class please help!! I do not have a clue as how to start this project : Project for This Course Goal: Develop a program that will automatically adjust a variable resistor until the maximum power is transferred to a load resister. Purpose: For this project, you will create a prototype of a circuit designed to transfer the maximum power...

  • This assignment should be relatively easy. Write a program in any reasonably high-level language, that reads...

    This assignment should be relatively easy. Write a program in any reasonably high-level language, that reads in numbers from a file, one per line, until it detects that a 0 (zero not an oh') has been entered The 0 does not count as part of the number series. After all numbers have been entered print out the number of items entered, the sum, the minimum value entered, the maximum value entered, and the arithmetic mean (one on each line), in...

  • i need this program in DEV C and starts with include stdio.h only Write a program...

    i need this program in DEV C and starts with include stdio.h only Write a program that receives two input values: a float number x=0, and an integer N>3. The program should output Y, which is the product of all the N numbers divided by x.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT