# Logic and Design

Number Analysis Program
Design a program that asks the user to enter a series of 20 numbers. The program should store the numbers in an array and then display the following data:
• The lowest number in the array
• The highest number in the array
• The total of the numbers in the array
• The average of the numbers in the array

Showing Answers 1 - 4 of 4 Answers

#### tnguyen25

• Jun 2nd, 2014

Thank you for your question.

```Code        private static int lowestNumberInArray(int[] numbers)
{
if (numbers.Length < 0)
throw new ArgumentException();

int lowest = numbers;

foreach (int i in numbers)
{
if (i < lowest)
lowest = i;
}
return lowest;
}

private static int biggestNumberInArray(int[] numbers)
{
if (numbers.Length < 0)
throw new ArgumentException();
int biggest = numbers;

foreach(int i in numbers)
{
if (i > biggest)
{
biggest = i;
}
}
return biggest;
}

private static int sumOfNumbersInArray(int[] numbers)
{
if (numbers.Length < 0)
throw new ArgumentException();
int sum = 0;

foreach (int i in numbers)
{
sum += i;
}
return sum;
}

private static double averageOfNumbersInArray(int[] numbers)
{
if (numbers.Length < 0)
throw new ArgumentException();

return sumOfNumbersInArray(numbers) / numbers.Length;
}```

Was this answer useful?  Yes

#### akhilesh

• Sep 14th, 2017

Int main()
{
int a;
for(i=0;i<10;i++)
{cin>>a[i];
}
i=0;
b= a[i];
c=b;
s=c;
avg=s;
for(i=1;i<<10;i++)
{
if(a[i] b=a[i];
if(a[i]>c)
c=a[i];
s=+a[i];
}
avg=s/10;
}

```Codeint main()
{
int a;
for(i=0;i<10;i++)
{cin>>a[i];
}
i=0;
b= a[i];
c=b;
s=c;
avg=s;
for(i=1;i<<10;i++)
{
if(a[i]<b)
b=a[i];
if(a[i]>c)
c=a[i];
s=+a[i];
}
avg=s/10;
}

```

Was this answer useful?  Yes

#### Shubhangi

• Oct 5th, 2017

I inserted a code but how to get exact decimal point answer for avg,I didnt get .

```Code#include<stdio.h>
main()
{
int arr;
int i,size;
size=sizeof(arr)/sizeof(arr);
printf("enter the array elemrnt......
");

for(i=0;i<size;i++)
//scanf("%d",&arr[i]);
arr[i]=rand()%100;

for(i=0;i<size;i++)
printf("%d      ",arr[i]);
printf("
");

//lowest number....
int temp=arr;
for(i=1;i<size;i++)
{
if(temp>arr[i])
temp=arr[i];
else
continue;
}
printf("lowest element=%d
",temp);
//highewst numer
temp=arr;
for(i=1;i<size;i++)
{
if(temp<arr[i])
temp=arr[i];
else
continue;
}
printf("highest element=%d
",temp);

//toatal of numbers
int sum =0;
for(i=0;i<size;i++)
{
sum=sum+arr[i];
}
printf("total of an array:%d
",sum);
//average
int avg;
avg=sum/size;
printf("average=%d
",avg);

}
```

Was this answer useful?  Yes

#### Teja

• Oct 8th, 2017

int arr[] = {4,2,6,1,7,12,10,11};
int min= arr;
int max= arr;
int total = 0;
int avg;
for(int i=0; i if(min > arr[i]) {
min = arr[i];
} else if(max < arr[i]) {
max = arr[i];
}
total = total + arr[i];
}
avg = total/arr.length;
System.out.println("Min : " + min + "Max: " + max + "Total:" + total + "avg" + avg);

Was this answer useful?  Yes

### Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.  