Dim n
n=inputbox ("Enter a number to display first 10 factors")
for i=1 to 10
msgbox n & " X " & i & " = " & n*i
next
Find the factorial of a given number
Dim n
n=inputbox ("Enter a number to compute factorial")
fact=1
for i=2 to n
fact=fact*i
next
msgbox "The factorial of " & n & " is " & fact
n=inputbox ("Enter a number to compute factorial")
fact=1
for i=2 to n
fact=fact*i
next
msgbox "The factorial of " & n & " is " & fact
Print even numbers in a range
Dim n
n=30
for i=1 to n
if i mod 2 = 0 then
msgbox "The number: " & i & " is even"
end if
next
n=30
for i=1 to n
if i mod 2 = 0 then
msgbox "The number: " & i & " is even"
end if
next
Find whether given number is a odd number
Dim n
n=inputbox ("Enter a number")
if n mod 2 = 0 then
msgbox "The number: " & n & " is not odd"
else
msgbox "The number: " & n & " is odd"
end if
n=inputbox ("Enter a number")
if n mod 2 = 0 then
msgbox "The number: " & n & " is not odd"
else
msgbox "The number: " & n & " is odd"
end if
Subscribe to:
Posts (Atom)