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 https://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

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Hey, wait!Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.