+ 1
Assignment & Increment Operators
/* When I input integers it outputs integers. However, when I input a decimal(ex:23.2) it outputs it with an extra "0" (ex:2320). I don't get the reason behind this. I started learning today. Please help. */ double x = 10; Console.WriteLine("Enter a number:"); double z = Convert.ToDouble(Console.ReadLine()); x *= z; Console.WriteLine(x)
1 Resposta
+ 1
first, tag your question with 'C#' next time, so we went have to guess which programming language you use.
second, i tried your code, and except for a missing semicolon at the end, it works as expected :
https://code.sololearn.com/cEf423PWkc4e/#
you can also find it also also in my public C# code playground as 'convert to double'.
At first I thought maybe your problem is due to other, later code, that prints the '0' after the original output, but WriteLine outputs a newline character after its output, so that's ruled out.