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

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Arithmetic/Integer step by step in the FreeBASIC 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 FreeBASIC programming language

Source code in the freebasic programming language

' FB 1.05.0 Win64

Dim As Integer i, j
Input "Enter two integers separated by a comma"; i, j
Print i;" + "; j; " = "; i + j
Print i;" - "; j; " = "; i - j
Print i;" * "; j; " = "; i * j
Print i;" / "; j; " = "; i \ j
Print i;" % "; j; " = "; i Mod j 
Print i;" ^ "; j; " = "; i ^ j
Sleep

' Integer division (for which FB uses the '\' operator) rounds towards zero

' Remainder (for which FB uses the Mod operator) will, if non-zero, match the sign
' of the first operand

  

You may also check:How to resolve the algorithm Sort three variables step by step in the Java programming language
You may also check:How to resolve the algorithm Sleep step by step in the NetRexx programming language
You may also check:How to resolve the algorithm Disarium numbers step by step in the PicoLisp programming language
You may also check:How to resolve the algorithm Monty Hall problem step by step in the Transact SQL programming language
You may also check:How to resolve the algorithm Descending primes step by step in the Sidef programming language