Thread: Print Maximum number

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    10

    Print Maximum number

    Hey guys-

    I'm having an issue with this program I wrote. It is supposed to have a user enter values and then output the maximum value of those values entered, using very basic C Programming. If only the sentinel value is entered, it will print out an error message. I have that working properly, but when I enter values, it outputs the maxmium, but when I enter the sentinel value (999), it outputs that as the maximum, which it shouldn't do. Any ideas? I'm probably just overlooking something very simple. I appreciate the help! Thanks!!

    -----------------
    Code:
    ...
    while (temp != 999)
    {               
       printf("Enter another value [enter 999 to stop]:\n");
       scanf("%f",&temp);
       counter == counter++; 
    
    	if ( temp > max) 
    	{
    	max = temp;
    	}
    	else if ( temp < max)
    	{
    	temp = temp;
    	}
    }
    
    if ( counter != 1 )
       {
       printf("The maximum is: %f\n", max);
       }
    else
       {
       printf("No valid entires:\n");
       }
    }
    Last edited by rmathus; 10-07-2003 at 08:28 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Shortest path algorithm with a maximum number of edges limit
    By blackslither in forum C Programming
    Replies: 4
    Last Post: 12-28-2008, 04:49 PM
  2. how to print a increasing number of words?
    By gershonj in forum C Programming
    Replies: 4
    Last Post: 07-11-2008, 07:36 AM
  3. adding a number to a number
    By bigmac(rexdale) in forum C Programming
    Replies: 11
    Last Post: 10-24-2007, 12:56 PM
  4. can't print all the permutations of a number
    By whizkid in forum C++ Programming
    Replies: 1
    Last Post: 12-11-2005, 10:41 AM
  5. help with a source code..
    By venom424 in forum C++ Programming
    Replies: 8
    Last Post: 05-21-2004, 12:42 PM