Please help me with the task: Maximum finder

Hello, I’m working on this task:

Write a program that reads two numbers from the console and then outputs the greater of the two numbers. Use a short (one line) version to read a string from the console and convert it to int.
Output example:
>123
>97
123

Here is my code:


namespace ConsoleInput
{
   public class TheMaximum
   {
       public static void Main(string[] args)
       {
           int a = int.Parse(Console.ReadLine());
           int b = int.Parse(Console.ReadLine());
           
           if (a > b)
           {
               Console.WriteLine(a);
           }
           else
           {
               Console.WriteLine(b);
       }
   }
}


Can anyone please help me to solve it?

one } is missing at the end

I don’t know :slight_smile: this was not in the condition
But why then is the correct pre-task?

Write a program that reads two numbers from the console and then outputs the lesser of the two numbers. Use a short (one line) version to read a string from the console and convert it to int .
For example:

123
97
97

{

        int a = int.Parse(Console.ReadLine());

        int b = int.Parse(Console.ReadLine());

       

        if (a > b)

        {

            Console.WriteLine(b);

        }

        else

        {

            Console.WriteLine(a);

        }

    }

In your initial code, you’ve missed

} 

after else.

1 Like

Oh yes, thank you!!!

1 Like