1. Create a program that will ask for 5 values for an array of integer then compute and display the sum and average of the elements. The program will use getSumAverage() to ask for the values, compute and display the sum of the elements.
2. Revise exercise 1, the getSumAverage() will be used to compute and display the sum and average and will use the array as its formal parameter.
3. Revise exercise 2, the getSumAverage() will be used to compute and display the sum then return the value of the average.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
(for number 1)
#include<iostream.h>
#include<conio.h>
int getSumAverage(int a[5]);
int b;
main()
{
clrscr();
int x[5], y;
cout<<"Enter 5 values: "<<endl;
for(y=0; y<5; y++)
{
cin>>x[5];
}
cout<<"The sum is "<<getSumAverage(x);
getch();
return 0;
}
int getSumAverage(int a[5]){
for (int i=0; i<5; i++)
b=b+a[i];
return b;
}
|
what must be the correct way to solve this problems together with the other 2..
I'm so sorry i am just a beginner but I really dont know anything about functions and that our teacher gave this as our project even though he did not teach us this...
If you could also solve this:
Create a program that will ask for 5 values of an array of integer
that represents 5 items’ prices bought by the customer. Compute and
display the total amount to pay. Ask for the cash then compute and display
the change. The program will use computeTotal() to compute and return the
total amount to pay and will use the array as its parameter. And computeChange()
to compute and return the change and will use the total amount and the cash
as its parameter.
thnks again... really need this by tomorrow..!