TO FIND THE SUM OF THE NATURAL NUMBERS USING FUNCTION IN VBSCRIPT

<html>
<head>
<script type="text/vbscript">

function sum(n)
dim I
sum=0
for i=1 to n
 sum=sum+i
  next
 end function

</script>
</head>

<body>

<script type="text/vbscript">
dim j,x
j=cint(inputbox("Enter the limit"))
 x=sum(j)
document.write("SUM=  "&x&"<br>")

</script>
</body>
</html>

No comments:

Post a Comment