:D

Discussion in 'Programming General' started by PsychicFreak, Aug 21, 2010.

:D
  1. Unread #1 - Aug 21, 2010 at 6:28 PM
  2. PsychicFreak
    Joined:
    Jun 6, 2008
    Posts:
    53
    Referrals:
    0
    Sythe Gold:
    0

    PsychicFreak Member

    :D

    guys how to make a c program that will get the maximum and minimum number of 5 variables?
     
  3. Unread #2 - Aug 22, 2010 at 1:38 AM
  4. Fastshot
    Joined:
    Apr 3, 2010
    Posts:
    364
    Referrals:
    0
    Sythe Gold:
    0

    Fastshot Forum Addict

    :D

    it will be something like:

    Code:
    // put in main
    int numbers[10]; //array stores the number values
    int x;
    int highest = 0;
    int lowest = 20000;
    
    for (x = 0; x < 10; x++)
    {
         if (highest < numbers[x]) highest = numbers[x];
         if (lowest > numbers[x]) lowest = numbers[x];
    
    }
    
    printf("%d %d", highest, lowest);
    
    I'm a newbie in c, but this should work.
     
< how to get the minimum value | All Ready Rsps >

Users viewing this thread
1 guest


 
 
Adblock breaks this site