Java program to find absolute value

Java program to find absolute value

Java program to find absolute value of negative number

Java program to find absolute value using math operation

Java program to find absolute value using math.abs

Program:-

import java.util.Scanner;

class group{
public static void main(String angt[]){
Scanner data = new Scanner(System.in);
int num;
System.out.println("Enter a number");
num=data.nextInt();
// Finding absolute value
num=Math.abs(num);
System.out.println("Absolute value:"+num);
}

Output:-

Enter a number
-25
Absolute value:25


Output:-

Enter a number
54
Absolute value:54




Learn Java:-
Java codes

Java Programs:-
List of Java Programs

One Comment

Add your comments here

Back to Top