When reading in two user numbers and using them in a equation, how to output a decimal solution?


So basically what I'm trying to do is have it so that the user enters in two numbers. It then takes these two numbers, divides them, then outputs the result.

Now originally I just did number1/number2. This works if the two numbers are say 10/5. That way it outputs 2. However if the numbers are 1/2 (the answer would be .5), it just outputs 0. I'm guessing that the reason its doing this is because it wont output decimal values.

Now I've done some research and tried different solutions. I know that if I had say Num1 = 1.03254m that it would work. However, since its a user imputed number I'm not sure how to get this to work.

by LAMPnewb via /r/csharp

Leave a Reply