Hi, I been trying this problem for 2 days and monday 31st is the due date :(
I tried to use a while loop but the numbers I get are not even close. What I did on the Enter your code is the codes below the question
//********************************************************************************************
//
// MaxMinIntegers.cpp
//
// Program that reads int values from a text file named "numbers01.txt"
// and writes out the largest and smallest values found. Numbers in the
// file may be separated by blanks or line breaks.
//
//********************************************************************************************
#include <fstream>
#include <iostream>
#include <cstdlib>
using namespace std;
int main() {
// Declare input stream
ifstream fin;
int min, max, val;
int isFirst = true;
fin.open("numbers01.txt");
// --------------------------------
// ----- ENTER YOUR CODE HERE -----
// --------------------------------
// --------------------------------
// --------- END USER CODE --------
// --------------------------------
fin.close();
cout << "Largest value is " << max << ", smallest value is " << min << "\n";
}
[B]Here is what I did[/B]
fin >> isFirst;
while (fin >> val)
fin >> val;
if (isFirst > val)
min = val
max = isFirst
else
max = val
min = isFirst