Math calculation on integer : int « Data Type « Perl






Math calculation on integer

    

#!C:\Perl\Bin\

$number_one = 5;
$number_two = 3;

print "Adding numbers:\n";
$result = $number_one + $number_two;
print "5 + 3 = $result \n\n";

print "Subtracting numbers:\n";
$result = $number_one - $number_two;
print "5 - 3 = $result \n\n";

print "Multiplying numbers:\n";
$result = $number_one * $number_two;
print "5 * 3 = $result \n\n";

print "Dividing numbers:\n";
$result = $number_one / $number_two;
print "5 / 3 = $result \n\n";

print "Raising numbers to a power:\n";
$result = $number_one ** $number_two;
print "5 raised to the power of 3 is $result \n\n";

print "Obtaining a remainder after a division (Modulo):\n";
$result = $number_one % $number_two;
print "5 Modulo 3 is $result \n\n";

   
    
    
    
  








Related examples in the same category

1.Declare an Integer
2.Integer type variable
3.Print a couple of integer literals in Perl.
4.Print number out
5.Using int() to convert 1.000001 to an integer
6.Using int() to convert 1.99999 to an integer
7.int 1.999,int 2.001
8.A program that displays integers and illustrates their size limitations.
9.Compare two values in the integer context
10.'<=>' operator returns 0 or -1 or 1
11.'Greater than or equal' operator
12.'Greater than', 'Less than' operator
13.'equal' operator for digits
14.'less than or equal' operator
15.'not equal' operator for digits
16.Get the remainder
17.Chop a number
18.'use integer'
19.To disable integer math within a block