Function definition

This is a discussion on Function definition within the C++ Programming forums, part of the General Programming Boards category; I am truely stumped please help me! The program will search a file of numbers of type int and write ...

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    1

    Angry Function definition

    I am truely stumped please help me!
    The program will search a file of numbers of type int and write the largest and the smallest numbers to the screen.

    #include <iostream.h>
    #include <fstream.h>
    #include <stdlib.h>
    #include <iomanip.h>

    void order(int one,int two,int three,int four, int five);

    int main()
    {
    ifstream high2low;

    high2low.open("numfile.txt");
    if(high2low.fail())
    {
    cout <<"Input file opening failed.\n";
    exit(1);
    }


    int first, second, third, fourth, fifth;

    high2low >> first >>second >>third>>fourth>>fifth;

    order(first, second, third, fourth, fifth);


    cout << first<<endl;
    cout << second<<endl;
    cout << third<<endl;
    cout << fourth<<endl;
    cout << fifth<<endl;



    high2low.close();
    return 0;
    }
    void order(int one,int two,int three,int four, int five)
    {
    int greatest,next;
    greatest =
    if(one>greatest)

    }

  2. #2
    Unregistered
    Guest
    the 1st will always be greatest until you test the others, so assign it to the variable named greatest. then test the others (its easier if they are in an array). so we have...

    greatest= first;

    if( second > greatest )
    {
    greatest = second;
    }
    etc.
    etc.

    repeat a similar thing for the lowest value

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginner Needs help in Dev-C++
    By Korrupt Lawz in forum C++ Programming
    Replies: 20
    Last Post: 09-28-2010, 01:17 AM
  2. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  3. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 04:45 PM
  4. load gif into program
    By willc0de4food in forum Windows Programming
    Replies: 14
    Last Post: 01-11-2006, 09:43 AM
  5. structure vs class
    By sana in forum C++ Programming
    Replies: 13
    Last Post: 12-02-2002, 06:18 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21