SORTING THE ELEMENTS IN ASCENDING ORDER IN VBSCRIPT

<html>
<head>
</head>
<body>

<script language="vbscript">
dim a(10)
dim i,t,j,item,n

n=InputBox("Enter the Limit of the array")

for  i= 1 to n
a(i)=InputBox("Enter the element")
next

document.write("Given elements are "+"<br>")
for i=1 to n
document.write(a(i)+"<br>")
next

 i=1
for each item in a
        for j=(i+1) to n
        If (a(i)>a(j)) then
                t=a(i)
               a(i)=a(j)
              a(j)=t
       End if
       next
  i=i+1
next

document.write("Sorted elements are "+"<br>")
for i=1 to n
document.write(a(i)+"<br>")
next
</script>
</body>
</html>

No comments:

Post a Comment