Ask 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 (var i = 0; i < = num; i++) {sum + = i; }println (sum); }

+4
Answers (1)
  1. 28 December, 04:06
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers