I'm doing a sum of two numbers exercise in Visual Studio 2022, in C# language.
Here is the current code:
class Program
{
static void Main(string[] args)
{
int x, y, sum;
Console.Write("Enter the value of X: ");
x = Console.Read();
Console.Write("Enter the value of Y: ");
y = Console.Read();
Console.WriteLine();
sum = x + y;
Console.WriteLine("SUM = " + sum);
Console.WriteLine();
Console.WriteLine("Press any key to close...");
Console.ReadKey();
}
}
It's happening that after typing a value for x and pressing ENTER, it's jumping straight to the sum calculation and giving me an inexplicable result of 66, but the correct thing would be to expect me to type the value of y and then add the two values.
here's a print of the console:
I'm not understanding this error, I would like an explanation of what is wrong in the code!