F# Recipe #3 – program to find if the number is positive or negative

Problem

Write a program in F# to find if the given number is a positive or negative number.

F# program to find if the number is positive or negative.

// Learn more about F# at http://DeveloperPublish.com
open System
let PositiveOrNegative param1 =
   if param1 > 0 then "positive"
   elif param1 < 0 then "negative"
   else "zero"

[<EntryPoint>]
let main argv = 
   Console.WriteLine("sign -3: {0}", (PositiveOrNegative -3))
   Console.ReadLine()
   0

Output

sign -3: negative

Leave a Reply