Answers for "minimum of 3 elements"

Go
0

minimum of 3 elements

def min3(a,b,c)
    ((a) < (b) ? ((a) < (c) ? (a) : (c)) : ((b) < (c) ? (b) : (c)))
end

print "Min of 3 elements = ", min3(5,6,7);
Posted by: Guest on May-21-2021
0

minimum of 3 elements

package main

import "fmt"

func min(a, b, c int) int {
	if a < b {
		if a < c {
			return a
		}
	} else {
		if b < c {
			return b
		}
	}
	return c
}

func main() {
    fmt.Printf("Minimum of 3 elements = %d", min(5,6,7))
}
Posted by: Guest on May-24-2021

Code answers related to "minimum of 3 elements"

Browse Popular Code Answers by Language