0

I am trying to learn C#, and have a basic question: I try to read two values from the user, and it doesn't work. Here is my code in C#:

        int a = 0;
        int n = 0;
        int s = 0;

        Console.WriteLine("Please enter the basic value");
        a = Console.Read();
        Console.WriteLine("Please enter the power");
        n = Console.Read();

        // Console.ReadKey();
        do
        {
            s = s * a;
            n--;
        }
        while (n > 1);
        Console.WriteLine("the solution is:" + s);
        Console.ReadKey();
Ali
  • 1
  • 1
  • My problem is the second read doesn't work! I mean, the value "a" is read, but it acts as if it jumps over reading "n" ! It doesn't even wait to read any key after the first read .... – Ali Mar 03 '18 at 21:40
  • It's because you are using `Console.Read()`. Try using `Console.ReadLine()`. – Tanner H. Mar 04 '18 at 00:46

0 Answers0