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

Questions by pokhara

Showing Answers 1 - 4 of 4 Answers

tnguyen25

  • Jun 2nd, 2014
 

Thank you for your question.

Code
  1.  

  Was this answer useful?  Yes

akhilesh

  • Sep 14th, 2017
 

Int main()
{
int a[10];
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;
}

Code
  1.  

  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
  1. #include<stdio.h>

  2. "enter the array elemrnt......

  3. "//scanf("%d",&arr[i]);"%d      ""

  4. ");

  5.  

  6. //lowest number...."lowest element=%d

  7. ",temp);

  8. //highewst numer"highest element=%d

  9. ",temp);

  10.  

  11. //toatal of numbers"total of an array:%d

  12. ",sum);

  13. //average"average=%d

  14. ",avg);

  15.  

  16. }

  17.  

  Was this answer useful?  Yes

Teja

  • Oct 8th, 2017
 

int arr[] = {4,2,6,1,7,12,10,11};
int min= arr[0];
int max= arr[0];
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.

 

Related Answered Questions

 

Related Open Questions