How to resolve the algorithm A+B step by step in the Wren programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm A+B step by step in the Wren programming language

Table of Contents

Problem Statement

A+B   ─── a classic problem in programming contests,   it's given so contestants can gain familiarity with the online judging system being used.

Given two integers,   A and B. Their sum needs to be calculated.

Two integers are written in the input stream, separated by space(s):

The required output is one integer:   the sum of A and B.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm A+B step by step in the Wren programming language

Source code in the wren programming language

import "io" for Stdin, Stdout

while (true) {
    System.write("Enter two integers separated by a space : ")
    Stdout.flush()
    var s = Stdin.readLine().split(" ")
    if (s.count < 2) {
        System.print("Insufficient numbers, try again")
    } else {
        var a = Num.fromString(s[0])
        var b = Num.fromString(s[s.count-1])
        System.print("Their sum is %(a + b)")
        return
    }
}

  

You may also check:How to resolve the algorithm Array concatenation step by step in the 68000 Assembly programming language
You may also check:How to resolve the algorithm Kolakoski sequence step by step in the Julia programming language
You may also check:How to resolve the algorithm Galton box animation step by step in the Java programming language
You may also check:How to resolve the algorithm Averages/Arithmetic mean step by step in the Vala programming language
You may also check:How to resolve the algorithm Shell one-liner step by step in the Java programming language