Ask Question
22 October, 14:27

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. 22 October, 15:02
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers