Please help me with the task: "Minimum checker"

Hello, I’m working on this task:

Write a program that reads integer count and then reads count integer numbers from the console and outputs their minimum. Example:
>3
>14
>57
>-10
-10

Here is my code:


namespace ForLoops
{
   class Minimum
   {
       static void Main(string[] args)
       {
           int minimum = 200000000;
           int forN = 100000000;

           for(int n = 0; n < forN; n++)
           {
           int number = int.Parse(Console.ReadLine());
           if(number < minimum)
           minimum = number;
           else
           Console.WriteLine($"{minimum}");
           }
       }
   }
}


Can anyone please help me to solve it?

Hi Sam_Vanesses,

Welcome to Codeasy!

The first thing that catches the eye is that you are trying to read 100000000 numbers from the console. Please, instead of 100000000, read the number from the console that represents the number of integers to read.

Another thing is that you are writing to console from the loop - this will make several outputs. Better find the minimum first, and then output after the loop.

Hope this helps!

Thanks! i solve it, it’s much better that way! :grinning: :grinning:

1 Like