How to resolve the algorithm Arithmetic/Integer step by step in the PowerShell programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Arithmetic/Integer step by step in the PowerShell programming language

Table of Contents

Problem Statement

Get two integers from the user,   and then (for those two integers), display their:

Don't include error handling. For quotient, indicate how it rounds   (e.g. towards zero, towards negative infinity, etc.). For remainder, indicate whether its sign matches the sign of the first operand or of the second operand, if they are different.

Bonus: Include an example of the integer divmod operator. For example: as in #Haskell, #Python and #ALGOL 68

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Arithmetic/Integer step by step in the PowerShell programming language

Source code in the powershell programming language

$a = [int] (Read-Host First Number)
$b = [int] (Read-Host Second Number)

Write-Host "Sum:                              $($a + $b)"
Write-Host "Difference:                       $($a - $b)"
Write-Host "Product:                          $($a * $b)"
Write-Host "Quotient:                         $($a / $b)"
Write-Host "Quotient, round to even:          $([Math]::Round($a / $b))"
Write-Host "Remainder, sign follows first:    $($a % $b)"


[Math]::Pow($a, $b)


  

You may also check:How to resolve the algorithm Roman numerals/Decode step by step in the Clojure programming language
You may also check:How to resolve the algorithm Associative array/Creation step by step in the Tcl programming language
You may also check:How to resolve the algorithm Operator precedence step by step in the zkl programming language
You may also check:How to resolve the algorithm Read a configuration file step by step in the SenseTalk programming language
You may also check:How to resolve the algorithm Draw a pixel step by step in the Lambdatalk programming language