Scala program to demonstrate 1’s complement (~) Operator 2023

In this post, we are going to demonstrate the 1’s complement (~) operator using the scala programming language.

object divineseo{
    def main(args: Array[String]){
        
        var number : Int = 0
        var result : Int = 0
        
        Console.println("Enter 1st number : ")
        number = scala.io.StdIn.readInt()
        
        result = ~number
        
        println("Result is : "+result)
    }
}
Scala

Output

Enter 1st number : 7
Result is : -8

Leave a Comment