मराठी
तामिळनाडू बोर्ड ऑफ सेकेंडरी एज्युकेशनएचएससी विज्ञान इयत्ता ११

Write a program in JavaScript to find the sum of 10 numbers using function? - Computer Applications

Advertisements
Advertisements

प्रश्न

Write a program in JavaScript to find the sum of 10 numbers using function?

थोडक्यात उत्तर

उत्तर

<html>
<head>
<Title> Function sum of 10 Numbers </Title>
<Script type = “text/Javascript”>
<!—
var input 1 = window.prompt (“Enter initial value : ”, “0”);
var input 2 = window.prompt (“Enter final value : ”, “0”);
var v1 = parse Int (input 1);
var v2 = parse Int (input 2);
var r = res (v1 , v2);
document, write In (“<br><h4><u> Function for sum of 10 Numbers </u> </h4>”);
document, write In (“Initial Number : “ +v1+” <br> Final Number : “+v2+”<br>
The result =”+r);
function result (n)
{
var r = n* (n+1)/2
return r;
//–>
</script>
</head>
<body>
</body>
</html>

OUTPUT

Enter initial value: 1

Enter final value: 10

Function for a sum of 10 numbers

Initial No: 1

Final No: 10

The result: 55

shaalaa.com
JavaScript Functions
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 16: JavaScript Functions - Evaluation [पृष्ठ ३३६]

APPEARS IN

सामाचीर कलवी Computer Applications [English] Class 11 TN Board
पाठ 16 JavaScript Functions
Evaluation | Q 2. | पृष्ठ ३३६
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×