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
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
APPEARS IN
संबंधित प्रश्न
The parameters work as ______.
Larger programs are divided into smaller are called ______.
Which of the following is used to enhance reusability and program clarity.
What is a function in JavaScript?
What is the use of function?
Write a note on Library functions.
Write a program in JavaScript to find the cube of a number using function.