| | |
question about array
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2004
Posts: 2
Reputation:
Solved Threads: 0
hi, all.
i have some problems to do array.
i am supposed to get the average and sum in given number of array.
but, i only got 1 in my all answers.
please, tell me what was wrong in my program.
thank you.
//hw for array
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
float ave(float x[],int n);
float sum(float x[],int n );
float diff(float x,float y);
float large(float x[],int n );
float small(float x[],int n);
const float size=10;
int main()
{
float array[10]={24.9,18.5,7.9,14.3,56.1,37.8,41.5,28.3,32.7,19.4};
cout<< "\na) \n\n";
cout<<"\naverage of these numbers: "<<ave<<endl;
return 0;
}
float ave(float x[],int n)
{
int i;
float sum=0;
for (i=0;i<n;i++)
sum +=x[i];
return (sum/n);
}
i have some problems to do array.
i am supposed to get the average and sum in given number of array.
but, i only got 1 in my all answers.
please, tell me what was wrong in my program.
thank you.
//hw for array
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
float ave(float x[],int n);
float sum(float x[],int n );
float diff(float x,float y);
float large(float x[],int n );
float small(float x[],int n);
const float size=10;
int main()
{
float array[10]={24.9,18.5,7.9,14.3,56.1,37.8,41.5,28.3,32.7,19.4};
cout<< "\na) \n\n";
cout<<"\naverage of these numbers: "<<ave<<endl;
return 0;
}
float ave(float x[],int n)
{
int i;
float sum=0;
for (i=0;i<n;i++)
sum +=x[i];
return (sum/n);
}
![]() |
Similar Threads
- Array question (C)
- 2d array question (C++)
- Question RE using Array Values in Case/If statements (Visual Basic 4 / 5 / 6)
- Little Simple array question :) (C)
- Question about array (PHP)
- strcmp of 2-D array (C)
Other Threads in the C++ Forum
- Previous Thread: never to old
- Next Thread: help with first and second problem
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class code coding compile compiler console conversion count database delete deploy desktop developer dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker list loop looping loops map math memory multiple news node number numbertoword output parameter pointer problem program programming project python random read recursion recursive reference rpg sorting string strings struct temperature template test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets





