Thread: check out my first program

  1. #16
    Ex scientia vera
    Join Date
    Sep 2007
    I am at awe...

    To the original poster:

    If you input three numbers, one of those will be the largest. You start by setting the largest number as your first number. Then you compare the following input numbers with the current largest number, which will be the first number you input, to begin with.

    If there aren't any numbers input that are larger than the first number, then what number is the largest number?
    If there are any numbers that are larger than the first number, then your if statements will trigger and you will set them as the largest number.

    in >> 4
    largest = 4

    in >> 3
    is largest(4) bigger than 3?
    largest = 4

    in >> 5
    is largest(4) bigger than 5?
    largest = 5.

    print largest(5)
    "What's up, Doc?"
    "'Up' is a relative concept. It has no intrinsic value."

  2. #17
    Registered User
    Join Date
    Sep 2009
    After a few edits I was able to get thefinal version to work. Thank you guys!

    	large = number1 ; //First number will be the largest number to compare
    if (large < number2) large = number2 ; //Then, compare large against number 2: 
    if (large < number3) large = number3 ; //Then, compare large against number 3: 
       cout << "The largest number is: " << large ;
    	cout << "\n";
                    cin.get ();
    		return 0;

  3. #18
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Katy, Texas
    Good job. A lot simpler, eh?
    Mac and Windows cross platform programmer. Ruby lover.

    Quote of the Day
    12/20: Mario F.:I never was, am not, and never will be, one to shut up in the face of something I think is fundamentally wrong.

    Amen brother!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to read a txt file into an array
    By Hitsugaya_KK in forum C Programming
    Replies: 49
    Last Post: 08-22-2009, 02:22 PM
  2. Replies: 7
    Last Post: 01-09-2009, 09:45 PM
  3. Suggestions for my Check Book program
    By Nor in forum C++ Programming
    Replies: 2
    Last Post: 11-17-2008, 06:44 PM
  4. program to check hard disk transfer rate
    By shadow99er in forum C Programming
    Replies: 3
    Last Post: 03-01-2002, 05:04 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM