using System;
using System.Collections.Generic;
using System.Text;
namespace max_min_of_n_number
{
class Program
{
static void Main(string[] args)
{
int n, i, j,t;
int[] a = new int[50];
Console.WriteLine("\tMAXIMUM & MINIMUM OF N NUMBERS");
Console.WriteLine("\t******************************");
Console.WriteLine("Enter the no of Elements");
n = int.Parse(Console.ReadLine());
Console.WriteLine("Enter the Elements one by One");
for (i = 1; i <= n; i++)
{
a[i] = int.Parse(Console.ReadLine());
}
for (i = 1; i <= n; i++)
{
for (j = i+1; j <= n; j++)
{
if (a[i] > a[j])
{
t = a[i];
a[i] = a[j];
a[j] = t;
}
}
}
Console.WriteLine("Minimum={0}", a[1]);
Console.WriteLine("Maximum={0}", a[n]);
}
}
}
using System.Collections.Generic;
using System.Text;
namespace max_min_of_n_number
{
class Program
{
static void Main(string[] args)
{
int n, i, j,t;
int[] a = new int[50];
Console.WriteLine("\tMAXIMUM & MINIMUM OF N NUMBERS");
Console.WriteLine("\t******************************");
Console.WriteLine("Enter the no of Elements");
n = int.Parse(Console.ReadLine());
Console.WriteLine("Enter the Elements one by One");
for (i = 1; i <= n; i++)
{
a[i] = int.Parse(Console.ReadLine());
}
for (i = 1; i <= n; i++)
{
for (j = i+1; j <= n; j++)
{
if (a[i] > a[j])
{
t = a[i];
a[i] = a[j];
a[j] = t;
}
}
}
Console.WriteLine("Minimum={0}", a[1]);
Console.WriteLine("Maximum={0}", a[n]);
}
}
}
No comments:
Post a Comment