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

Stuck on this challenge: Define an array of const integers, constArray, initiali

ID: 3659822 • Letter: S

Question

Stuck on this challenge: Define an array of const integers, constArray, initialized with 5 value of your choice. Define an array of constant pointers int,constPtrArray, initialized with the addresses of elements in constArray. Write a function named averageInt that when called as averageInt(constPtrArray, 5) will return a double holding the average of the integers in constArray. Write a driver to create the specified arrays and function. It should print out the values in constArray, call averageInt, and print out the calculated average. Thanks in advance.

Explanation / Answer

#include #include struct money { char name[80]; float balance; }; int bank(int, struct money *); int main(void) { struct money *p; int x = 1; bank(x,p); printf("%s %f ",p[x].name,p[x].balance); return 0; } int bank(int mode, struct money p) { static struct money abank[3]; //bank0 strcpy(abank[0].name,"Arthur's Bank"); abank[0].balance = 43.57; //bank1 strcpy(abank[1].name,"Pete's Savings & Loan"); abank[1].balance = 1123.80; //bank2 strcpy(abank[2].name,"T.G. Chelt's Trust"); abank[2].balance = 340.23; p = &abank[mode]; return 0; }