Home.NETF# Recipe #3 – program to find if the number is positive or negative

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

Share:

Leave a Reply

You May Also Like

In this post, you’ll learn about the error message “WorkbookNotSupported – The file you selected cannot be opened because it...
  • .NET
  • December 17, 2022
In this post, you’ll learn about the error message “SpecifiedRangeNotFound – The requested range does not exist in the sheet.”...
  • .NET
  • December 17, 2022
In this post, you’ll learn about the error message “SheetRangeMismatch – The sheet provided as the sheet argument is not...
  • .NET
  • December 17, 2022