|
-
October 8th, 2010, 04:31 AM
#1
Visual Basic
1. Modify the summation procedure in lesson in action and use Do-Until loop instead.
2. How many times does the following loop iterates?
intX = 20
Do While (intX > = 1)
intX = intX + 1
Loop
3. Create a program that asks for a number and computers for its factorial. The Factorial of 3 is 6 (1 x 2 x 3).Factorial of 5 is 120 (1 x 2 x 3 x 4 x 5). You may use the same Form and change the caption of the button from summation to Factorial. Also, make sure that the user enters a number using the IsNumeric () Function.Display appropriate messages in the label if the user enters non-numeric values.
-
October 8th, 2010, 09:58 AM
#2
Re: Visual Basic
Looks like homework.
You need to do this yourself.
If you are stuck show what you have done and where you have a problem and you will get some help.
Always use [code][/code] tags when posting code.
-
October 15th, 2010, 01:59 PM
#3
Re: Visual Basic
 Originally Posted by azzaq
2. How many times does the following loop iterates?
intX = 20
Do While (intX > = 1)
intX = intX + 1
Loop
Are U crazy? It will iterate while intX>=1. Pizdets!
-
October 15th, 2010, 06:45 PM
#4
Re: Visual Basic
Well, what do you set it as BEFORE the first line? How is it supposed to know where to STOP? Might you want to SUBTRACT instead?
-
October 18th, 2010, 11:14 AM
#5
Re: Visual Basic
Well, the serious answer is: the loop iterates 32747 times and then the program crashes with an overflow error That is because intX will then try to increment from 32767 to 32768 which is not allowed. (assumed intX was declared As Integer).
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|