Write an app that finds the smallest of several integers. Assume
that the first value read specifies the number of values to input from the user. when the user is prompted to "Enter the number of values to read: " that he is required to enter a positive integer before the application will continue.
Thanks
Loading

VulpesPosted Oct 16, 2014, 12:33 PM
Tommy ProfetaPosted Oct 16, 2014, 12:47 PM
Tommy ProfetaPosted Oct 16, 2014, 12:10 PM
VulpesPosted Oct 16, 2014, 11:49 AM
if (i < n) Console.WriteLine("Only {0} attempt(s) remaining\n", n - i);
Tommy ProfetaPosted Oct 16, 2014, 11:44 AM
VulpesPosted Oct 16, 2014, 11:25 AM
using System;
class Program
{
static void Main()
{
int n;
do
{
Console.Write("Enter the number of values to read : ");
int.TryParse(Console.ReadLine(), out n);
}
while (n < 1);
int min = int.MaxValue;
int v = 0;
for(int i = 1; i <= n; i++)
{
Console.Write(" Value {0} : ", i);
int.TryParse(Console.ReadLine(), out v);
if (i < n) Console.WriteLine("{0} value(s) remaining\n", n - i);
if (v < min) min = v;
}
Console.WriteLine("\nThe smallest number entered is {0}", min);
Console.ReadKey();
}
}
Tommy ProfetaPosted Oct 16, 2014, 11:05 AM
VulpesPosted Oct 16, 2014, 10:48 AM
using System;
class Program
{
static void Main()
{
int n;
do
{
Console.Write("Enter the number of values to read : ");
int.TryParse(Console.ReadLine(), out n);
}
while (n < 1);
int min = int.MaxValue;
int v = 0;
for(int i = 1; i <= n; i++)
{
Console.Write(" Value {0} : ", i);
int.TryParse(Console.ReadLine(), out v);
if (v < min) min = v;
}
Console.WriteLine("\nThe smallest number entered is {0}", min);
Console.ReadKey();
}
}