You are on page 1of 9

# 1.

JavaScript program to find the greatest common divisor (gcd) of two positive
numbers

if ( ! b) {

return a;

## return gcd(b, a % b);

};

console.log(gcd(2154, 458));

output=2

else

## var list = range(start_num, end_num - 1);

list.push(end_num - 1);

return list;

};

console.log(range(2,9));

## out put =[3,4,5,6,7,8]

3. JavaScript program to compute the sum of an array of integers

## var array_sum = function(my_array) {

if (my_array.length === 1) {

return my_array[0];

else {

## return my_array.pop() + array_sum(my_array);

};

console.log(array_sum([1,2,3,4,5,6]));

output=21

if (n === 0)

return 1;

else

## return a * exponent(a, n-1);

};

console.log(exponent(4, 2));

output=16
5. JavaScript program to get the first n Fibonacci numbers.

if (n===1)

else

## s.push(s[s.length - 1] + s[s.length - 2]);

return s;

};

console.log(fibonacci_series(8));

output=[0.1.1.2.3.5,8,13,21]

## 6. JavaScript program to check whether a number is even or not

function is_even_recursion(number)

if (number < 0)

number = Math.abs(number);

if (number===0)

{
return true;

if (number===1)

return false;

else

number = number - 2;

return is_even_recursion(number);

console.log(is_even_recursion(234)); //true

console.log(is_even_recursion(-45)); // false

console.log(is_even_recursion(-45)); // false

output=true

false

false

return half;

## if (target > this[half])

{
return half + this.slice(half,this.length).br_search(target);

else

## return this.slice(0, half).br_search(target);

};

l= [0,1,2,3,4,5,6];

console.log(l.br_search(5));

output=5
1.W.A.P to calculate the expression a = 5-2*2/5^3 in vb script
<html>

<script type="text/vbscript">

Dim a
a = 5-2*2/5^3
document.write(a)
</script>

<body>

</body>
</html>

## 2.W.A.P. to find the age between 18-70 in vb script

<html>
<script type="text/vbscript">
Dim age
If age<18 Then
document.write("You are too young.")
ElseIf age<45 Then
document.write("You are still young.")
ElseIf age<70 Then
document.write("You are getting older.")
Else
document.write("You are too old.")
End If

</script>

<body>
</body>
</html>
3.vbscript to find the vowel in a word

<html>

<script type="text/vbscript">
Dim name, length
length = Len(name)’Gives length of the input string

For i = 1 To length
txt = Mid(name,i,1)'Returns a specified number of characters from a string, the
first parameter is the string, second parameter is the starting position and third
parameter is the number of characters to return
If txt="a" or txt="A" or txt="e" or txt="E" or txt="i" or txt="I" or txt="o" or
txt="O" or txt="u" or txt="U" Then
counter = counter+1
End If
Next
document.write("Hi " & name & "!!!Your name contains " & counter & " vowels.")
</script>

<body>

</body>
</html

## 4.vb script to find the result

<script type="text/vbscript">
Function returnResult(ByRef value)
value = value +1
returnResult = value
End Function
Dim x
x=5
call returnResult(x)
document.write(x)
</script>

## 5. vb script to print number between 0-5

For i=5 To 0 step -1
WScript.Echo i
Next
4. vbscript to find marks in the subject

<html>
<body>
<script type="text/vbscript">
Option Explicit
‘Dim markE, markM, markT
markE=90
markM=86
markT=markE+markM
document.write("Your marks in English is " & markE & "." & "<br />")
document.write("Your marks in Mathematics is " & markM & "." & "<br />")
document.write("Your total marks is " & markT & ".")
</script>

</body>
</html>

## 5. vbscript to get marks with student name and id number

<html>
<body>

<script type="text/vbscript">
Option Explicit
Dim students(19), marks(19)
students(0) = "John"
marks(0) = 95
students(1) = "Emma"
marks(1) = "83"
students(2) = "Kevin"
marks(2) = 87

document.write(students(0) & " has scored " & marks(0) & ".<br />")
document.write(students(1) & " has scored " & marks(1) & ".<br />")
document.write(students(2) & " has scored " & marks(2) & ".<br />")
</script>

</body>
</html>
6. program to find the area

<html>