Data update

This commit is contained in:
Ingy döt Net 2025-06-11 20:16:52 -04:00
parent 72eb4943cb
commit 4d5544505c
2347 changed files with 62432 additions and 16731 deletions

View file

@ -0,0 +1,24 @@
import ballerina/io;
function divmod(int a, int b) returns [int, int] {
return [a / b, a % b];
}
function pow(int n, int e) returns int {
if e < 1 { return 1; }
int prod = 1;
foreach int i in 1...e { prod *= n; }
return prod;
}
public function main() returns error? {
int a = check int:fromString(io:readln("first number: "));
int b = check int:fromString(io:readln("second number: "));
io:println("sum: ", a + b);
io:println("difference: ", a - b);
io:println("product: ", a * b);
io:println("integer quotient: ", a / b); // rounds towards zero
io:println("remainder: ", a % b); // sign matches sign of first operand
io:println("exponentiation: ", pow(a, b));
io:println("divmod ", divmod(a, b));
}

View file

@ -0,0 +1,14 @@
PROC main:
LOCAL a%,b%
PRINT "Please enter a number:",
INPUT a%
PRINT "Please enter another number:",
INPUT b%
PRINT a%;"+";b%;"=";a%+b%
PRINT a%;"-";b%;"=";a%-b%
PRINT a%;"×";b%;"=";a%*b%
PRINT a%;"÷";b%;"=";a%/b%
PRINT a%;"%";b%;"=";a%-a%/b%*b%
PRINT a%;"^";b%;"=";a%**b%
GET
ENDP

View file

@ -1,13 +1,13 @@
import "io" for Stdin, Stdout
System.write("first number: ")
Stdout.flush()
var a = Num.fromString(Stdin.readLine())
System.write("second number: ")
Stdout.flush()
var b = Num.fromString(Stdin.readLine())
import "./ioutil" for Input, Stdin
var divmod = Fn.new { |a, b| [(a / b).floor, a % b] }
var a = Input.integer("first number: ")
var b = Input.integer("second number: ")
System.print("sum: %(a + b)")
System.print("difference: %(a - b)")
System.print("product: %(a * b)")
System.print("integer quotient: %((a / b).floor)")
System.print("remainder: %(a % b)")
System.print("exponentiation: %(a.pow(b))")
System.print("divmod: %(divmod.call(a, b))")