Sha256: 1c8005b2df22f9945fe52a6c185eb54092a617b83d6e50bd26d48ada309ef915

Contents?: true

Size: 864 Bytes

Versions: 10

Compression:

Stored size: 864 Bytes

Contents

// Arithmetic-integer in V (Vlang)
// Tectonics: v run arithmetic-integer.v
module main
import math
import os

// starts here
pub fn main() {
    mut a := 0
    mut b := 0

    // get numbers from console
    print("Enter two integer numbers, separated by a space: ")
    text := os.get_raw_line()
    values := text.split(' ')
    a = values[0].int()
    b = values[1].int()

    // 4 basics, remainder, no exponentiation operator
    println("values:           a $a, b $b")
    println("sum:              a + b = ${a + b}")
    println("difference:       a - b = ${a - b}")
    println("product:          a * b = ${a * b}")
    println("integer quotient: a / b = ${a / b}, truncation")
    println("remainder:        a % b = ${a % b}, sign follows dividend")

    println("no exponentiation operator")
    println("  math.pow:    pow(a,b) = ${math.pow(a,b)}")
}

Version data entries

10 entries across 7 versions & 1 rubygems

Version Path
zettacode-0.1.7 files.zettacode/arithmetic.integer/v_(vlang).txt
zettacode-0.1.6 files.zettacode/arithmetic.integer/v_(vlang).txt
zettacode-0.1.6 files.zettacode2/arithmetic.integer/v_(vlang).txt
zettacode-0.1.5 files.zettacode/arithmetic.integer/v_(vlang).txt
zettacode-0.1.5 files.zettacode2/arithmetic.integer/v_(vlang).txt
zettacode-0.1.4 files.zettacode/arithmetic.integer/v_(vlang).txt
zettacode-0.1.4 files.zettacode2/arithmetic.integer/v_(vlang).txt
zettacode-0.1.3 files.zettacode/arithmetic.integer/v_(vlang).txt
zettacode-0.1.2 files.zettacode/arithmetic.integer/v_(vlang).txt
zettacode-0.1.1 zettacode.files/arithmetic.integer/v_(vlang).txt