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 count = int.Parse(Console.ReadLine());
int a = int.Parse(Console.ReadLine());
for(int i = 0; i < count; i++)
{
int b = int.Parse(Console.ReadLine());
if (b < a)
a = b;
}
Console.WriteLine(a);
}
}
}
what is wrong with this solution??
error:-
System.FormatException: Input string was not in a correct format.
at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, TypeCode type)
at System.Number.ParseInt32(ReadOnlySpan`1 value, NumberStyles styles, NumberFormatInfo info)
at System.Int32.Parse(String s)
at ForLoops.Minimum.Main(String[] args)