Ask Question
16 November, 20:25

What is the output of the following program? function start () {var x = 5; sumTo (x); println (x); }function sumTo (num) {var sum = 0; for (var i = 0; i < = num; i++) {sum + = i; }println (sum); }

+2
Answers (1)
  1. 17 November, 00:22
    0
    Output of the following code:-

    5

    15

    Explanation:

    There are two functions in the code given above.

    function start () function sumTo (num)

    start function is used to call the second function sumTo with variable x whose value is 5.

    in function there is a for loop which runs from i 0 to num and adds up i to the sum. So the sum will be 15 when the argument is 5.

    start function also prints the value of x and the sum is printed in the new line. So the output is

    5

    15.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “What is the output of the following program? function start () {var x = 5; sumTo (x); println (x); }function sumTo (num) {var sum = 0; for ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers