Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Implement the function avgLst() that takes no parameters and inputs from the use

ID: 3663518 • Letter: I

Question

Implement the function avgLst() that takes no parameters and inputs from the user a list of numbers. The function returns the average of the numbers in the list. If the list entered by the user is empty, the average returned should be 0.0. You may assume that the list provided by the user contains only numbers, either floating point or integer or both. The information below shows how you would call the function avgLst() and what it would display for several different user interactions. Hint: Remember that eval() is a useful function for transforming strings input from the user into other types.

Python 3.4.1 Shell File Edit Shel Debug Options Windows Help avgLst Please enter alist: [1, 2, 3, 4] 2.5 avgLst Please enter a list: -3.5, 2.7, 8 2.4 avgLst Please enter a list: 0.0 Ln: 26 Col: 4

Explanation / Answer

you didnot briefly and without going into detai which programming language is required. i write program in c language

#include<stdio.h>

#define MAX 100 //declare the size of array 100
int num[MAX]; // declaration of function
int CalculateAverage(int);
main()
{
int i,n;
int average;
printf(" program to find average );
printf(" Enter the Number : ");
scanf("%d",&n); //enter the data by the user
printf(" Enter the %d number: ",n);
for(i=0;i<n;i++)
{
printf(" number[%d]:",i+1);
scanf("%d",&num[i]);   
  
}
average=CalculateAverage(n); //calling function
printf(" The Average Of Marks is: %d ",average);
getch();
}


int CalculateAverage(int no) //function body
{
int avg;
int sum=0;
int i;
for(i=0;i<no;i++)
{
sum = sum + num[i]; //Adding all marks to get sum
}

avg=sum/no; //calculating average
return avg;
}

#include<stdio.h>
#include<conio.h>
#define MAX 100 //declare the size of array 100
int num[MAX]; // declaration of function
int CalAverage();
main()
{
int i,n;
int average;
clrscr();
printf(" program to find average " );
printf(" Enter the size of the list: ");
scanf("%d",&n); //enter the data by the user
printf(" Enter the number: ",n);
for(i=0;i<n;i++)
{
printf(" number:",i+1);
scanf("%d",&num[i]);   
  
}
average=CalAverage(n); //calling function
printf(" The Average Of Marks is: %d ",average);

}


int CalAverage(int no) //function body
{
int avg;
int sum=0;
int i;
for(i=0;i<no;i++)
{
sum = sum + num[i]; //Adding all marks to get sum
}

avg=sum/no; //calculating average
return avg;
}