Write a program that calculates the absolute value of an integer entered by the user.

******** In Algorithm ********

Algorithm Variables m :integer Begin write("Enter a number:") read(m) if( m >= 0) then write(" the absolute value of ",m," is ",m) else write("the absolute value of",m," is ",-m) next End

Result ==> Enter a number : -7 the absolute value of -7 is 7

******** In C ********

#include <stdio.h> int main() { int m ; printf(" Enter a number :") ; scanf("%d",&m); if( m >= 0) printf("the absolute value of %d is %d",m,m); else printf("the absolute value of %d is %d",m,-m); return 0; }

******** In C++ ********

#include <iostream> using namespace std; int main(){ int m ; cout<<" Enter a number :" ; cin>>m; if( m >= 0) cout<<"the absolute value of "<<m<<"est"<<m; else cout<<"the absolute value of "<<m<<" est "<<-m; return 0; }

******** in Python ********

A = float(input("Enter A :")) if A < 0 : print("the absolute value of",A,"is",-A) else : print("the absolute value of",A,"est",A)


******** in JAVA ********

import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner (System.in);

System.out.print("Enter m:");
int m = sc.nextInt();

if( m > 0)

System.out.print("the absolute value of "+m+" is "+m);

if( m < 0)
  System.out.print("
the absolute value of "+m+" est "+-m);
}
}

********* En C# *******

using System;
public class Ex8 {
public static void Main(string[] args)
{ float N;
Console.Write("Enter N:");
N=float.Parse(System.Console.ReadLine());
if (N>=0 )
Console.WriteLine ("
the absolute value of"+N+" is "+N);
else
Console.WriteLine ("
the absolute value of "+N+" is "+-N
}
}