Scala - Find given number is EVEN/ODD using 'IF' statement Code Example

The code for Find given number is EVEN/ODD using 'IF' statement

// Scala program to find given number is EVEN/ODD 
// using "IF" statement

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


/*
Output:
Enter number:13
Number is ODD
*/
Code by IncludeHelp, on August 12, 2022 23:09

Comments and Discussions!

Load comments ↻






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