Monday, May 24, 2010

How to make a program in visual basic which shows a factorial output?

there are only 2 textboxes which are to be used . in the first textbox, the last number will be entered and on the second textbox, the output which is the sum of all the numbers (factorial) should be displayed.

How to make a program in visual basic which shows a factorial output?
use a FOR/NEXT loop with the STEP argument to DECRIMENT the variable





Dim intCounter as integer





STATIC intSolution as Integer





FOR intCounter = 5 to 1 STEP -1





intSolution = (some calculation performed against intCounter)





Next intCounter





This is using VB-6 code, since you didn't specify a particular version of the laguage. Check http://www.pscode.com for great sample codes.
Reply:use double variables...
Reply:Did you mean to use the word SUM ? I'm not trying to be picky, but a factorial is not a sum.


A factorial is : 5! = 1 x 2 x 3 x 4 x 5 = 120 .


A sum is : 1 + 2 + 3 + 4 + 5 = 15.





in C ++ for example


you can assign a variable to the user's input of the number 5


then you can make a loop ----


while( whole_num %26gt; 1 )


{


total = total * whole_num;


whole_num = whole_num - 1;


}





I'm not sure how to write this in Visual Basic, but if you understand my logic here, you should be able to translate it into other languages.
Reply:try vbcode.com

song meanings

No comments:

Post a Comment