using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class AverageValue
{
public void sumAverageElements(int[] arrA, int size)
{
int sum = 0;
int average = 0;
for (int x = 0; x < size; x++)
{
sum += arrA[x];
}
average = sum / size;
Console.WriteLine("Sum Of Array is : " + sum);
Console.WriteLine("Average Of Array is : " + average);
Console.ReadLine();
}
public static void Main(string[] args)
{
int size;
Console.WriteLine("Enter the Size :");
size = Convert.ToInt32(Console.ReadLine());
int[] y = new int[size];
Console.WriteLine("Enter the Elements of the Array : ");
for (int x = 0; x < size; x++)
{
y[x] = Convert.ToInt32(Console.ReadLine());
}
int len = y.Length;
AverageValue Objavg = new AverageValue();
Objavg.sumAverageElements(y, len);
}
}
---------------------
OUTPUT:-
Enter the Size :
3
Enter the Elements of the Array :
4
6
7
Sum Of Array is : 17
Average Of Array is : 5
using System.Collections.Generic;
using System.Linq;
using System.Text;
class AverageValue
{
public void sumAverageElements(int[] arrA, int size)
{
int sum = 0;
int average = 0;
for (int x = 0; x < size; x++)
{
sum += arrA[x];
}
average = sum / size;
Console.WriteLine("Sum Of Array is : " + sum);
Console.WriteLine("Average Of Array is : " + average);
Console.ReadLine();
}
public static void Main(string[] args)
{
int size;
Console.WriteLine("Enter the Size :");
size = Convert.ToInt32(Console.ReadLine());
int[] y = new int[size];
Console.WriteLine("Enter the Elements of the Array : ");
for (int x = 0; x < size; x++)
{
y[x] = Convert.ToInt32(Console.ReadLine());
}
int len = y.Length;
AverageValue Objavg = new AverageValue();
Objavg.sumAverageElements(y, len);
}
}
---------------------
OUTPUT:-
Enter the Size :
3
Enter the Elements of the Array :
4
6
7
Sum Of Array is : 17
Average Of Array is : 5
--------------------------------------------
No comments:
Post a Comment