Scala - Find given number is POSITIVE/NEGATIVE using 'IF' statement Code Example

The code for Find given number is POSITIVE/NEGATIVE using 'IF' statement

// Scala program to find given number is POSITIVE/NEGATIVE 
// using "IF" statement

object Sample{  
  def main(args:Array[String]){  
    var num:Int = 0;
    
    print("Enter number:")
    num=scala.io.StdIn.readInt()
    
    if(num>=0)
      println("Number is POSITIVE")
    else
      println("Number is NEGATIVE")
  }
}


/*
Output:
Enter number:-32
Number is NEGATIVE
*/
Code by IncludeHelp, on August 12, 2022 23:10

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.