maximum and minimum age calculate in C#
Object
Screen Shot
Object
Write a program in C# that
takes age of 10 people as input and displays the minimum, maximum and average
age using Arrays.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace array_oop
{
class Program
{
static void Main(string[] args)
{
float div = 0;
float average = 0;
int i = 0;
int max = 0;
int min = 50;
int[] array = new int[15];
for (; i < array.Length; i++)
{
Console.Write("Enter The Integer :");
array[i] = int.Parse(Console.ReadLine());
average += array[i];
}
div=average / 15;
for (int k = 0; k
< array.Length; k++)
{
if (array[k] > max)
{
max = array[k];
}
}
for (int
j = 0; j < array.Length; j++)
{
if (array[j] < min)
{
min = array[j];
}
}
Console.WriteLine("\nMin Num
:" + min);
Console.WriteLine("\nMax Num
:" + max);
Console.WriteLine("\nAverage
:" + div);
Console.Write("\n");
}
}
}
No comments:
Post a Comment