Integer Parameters

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jvzj017
    New Member
    • Oct 2006
    • 10

    Integer Parameters

    Write the definition of a function min that has two int parameters and returns the smaller.
  • dariophoenix
    New Member
    • Oct 2006
    • 34

    #2
    Originally posted by Jvzj017
    Write the definition of a function min that has two int parameters and returns the smaller.
    Hey, try and do them yourself... How else are you gonna learn?...=)

    int min(int a, int b){
    if (a<=b) return a;
    else return b;
    }

    Bye, I'm going to sleep...

    Comment

    • dynamicleo
      New Member
      • Oct 2006
      • 14

      #3
      Code:
      int min( int x, int y) {
          return x < y ? x : y;
      }

      Comment

      Working...