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

Your email address will not be published. Required fields are marked *

You May Also Like

In this post, you’ll learn about the error message “FileOpenAccessDenied – You do not have permissions to open this file...
  • .NET
  • December 3, 2024
You might have had a situation where your code once worked fine in ASP.NET application but now throws the below...
  • .NET
  • December 3, 2024
C# uses the flower bracket “{” and “}” to identify the block or scope of the function or program ....
  • .NET
  • December 3, 2024