Download VBScript Examples PDF

TitleVBScript Examples
TagsTechnology Software Computer Programming Software Engineering Areas Of Computer Science
File Size127.0 KB
Total Pages8
Document Text Contents
Page 5

For more Scripts & QTP For more Scripts & QTP Documents Visit: www.gcreddy.comDocuments Visit: www.gcreddy.com

NextNext

11) Display Natural numbers in reverse order up to n?11) Display Natural numbers in reverse order up to n?

Dim num,nDim num,n
n=Inputbox ("Enter a Vaule")n=Inputbox ("Enter a Vaule")
For num=n to 1 step -1For num=n to 1 step -1
msgbox nummsgbox num
NextNext

12) Display Natural numb12) Display Natural numbers sum up to ers sum up to n? n? (Using For...Nex(Using For...Next Loop)t Loop)

Dim num, n, sumDim num, n, sum
n= inputbox ("Enter a Value")n= inputbox ("Enter a Value")
sum=0sum=0
For num= 1 to n step 1For num= 1 to n step 1

sum= sum+numsum= sum+num
NextNext

msgbox summsgbox sum

13) Display Natural numbers sum 13) Display Natural numbers sum up to n? (using While...Wend Loop)up to n? (using While...Wend Loop)

Dim num, n, sumDim num, n, sum
n= inputbox ("Enter a Value")n= inputbox ("Enter a Value")
While num <=cdbl (n)While num <=cdbl (n)

sum= sum+numsum= sum+num
num=num+1num=num+1

WendWend
msgbox summsgbox sum

14) Display Natural numbers sum 14) Display Natural numbers sum up to n? (Using Do...Until...Loop)up to n? (Using Do...Until...Loop)

Dim num, n, sumDim num, n, sum
n= inputbox ("Enter a Value")n= inputbox ("Enter a Value")
sum=0sum=0
num=1num=1
DoDo

sum= sum+numsum= sum+num
num=num+1num=num+1

Loop Until num =cdbl (n+1)Loop Until num =cdbl (n+1)
msgbox summsgbox sum

15) Write a Function for 15) Write a Function for Natural Numbers sum up to n?Natural Numbers sum up to n?

Function NNumCou (n)Function NNumCou (n)
Dim num, sumDim num, sum
sum=0sum=0
For num= 1 to n step 1For num= 1 to n step 1

sum= sum+numsum= sum+num
NextNext
msgbox summsgbox sum
End FunctionEnd Function

For Software Testing Documents visit:For Software Testing Documents visit: ww.gcreddy.netww.gcreddy.net 55

Similer Documents