07 December, 2013

A Program To Find The Factorial of a Given Number

Private Sub Command1_Click()
Dim n As Single
Dim f As Single
Dim i As Single
f = 1
n = InputBox("ENTER THE NUMBER")
For i = 1 To n

f = f * i
Print f
End Sub

Here we make use of looping statements.
The Looping statement is a statement that helps in executing a program while a certain condition prevails.
We have the "While" loop, "Do" loop and the "For" loop.
Each of these have their blocks and their forms of use. The block of "While" is "Wend", the block of "Do" is "Loop Until" and the block of "For" is "Next".
We also make use of a counter which is represented with "i"
Their formats of use are as follows:
WHILE LOOP; While/Condition/V.B Statement/ WEND
DO LOOP; Do/V.B Statement/Loop Until/Condition
FOR LOOP; For i="start value"to "end value"/V.B Statement/Next

No comments:

Post a Comment