Thread: Help[c++]
View Single Post
Old 01-10-2007   #4
sayo9394
Registered Member
 
sayo9394's Avatar
 
Last Online: 05-30-2010
Join Date: Dec 2006
Posts: 131
Thanks: 1
Thanked 3 Times in 2 Posts
Groans: 0
Groaned at 0 Times in 0 Posts
Default Re: Help[c++]

where can i start???

Quote:
Originally Posted by Chriseid06
double maximum(float n[30]);
{

for(i=1;i<=n;i++)
max=n[i];

}
well, n is an array, its not an int and its not the size of the array... so u can't have i <= n.
and inorder to get max, you should compare the contents of the array.
somethin like
Code:
double temp;
temp = n[0];
for (int i = 1; n < arraysize; i++)
{
    if (n[i] > temp)
          temp = n[i]
}

return temp;
Quote:
Originally Posted by Chriseid06
double moyenne (float a,int n)
{ for(i=1;i<=n;i++)
s=s+n[i];
m=s/n;
}
the above code is good... you should have done the same for the min and max... i think wat u've done is copied and pasted the code...
i'll explain what the function is expecting.
Code:
double moyenne (float a[], int n)
what "a" stands for is the array, and n is the size of the array.
instead of using n[i], u should use a[i]

Quote:
double minimum (float n[30]);
{
min=n[0];
for(i=1;i<=n;i++)
if(n[i]<n[i-1])
min=n[i];
}
good stuff, the logic is correct... again ur using the i <= n, n doesn't hold any value...

i'm not sure if i should give you the code i wrote, or get u to read the compiler errors, and research them so u can learn about your mistakes.

Quote:
int main()
{
float n;
do{
cout<<"Entrez le nombre des eleves (maximum=30"<<endl;
cin>>n;
}while(n>30);
cout<<"Entrez les notes:"<<endl;
for(i=1;i<=n;i++)
cin>>n[i];
cout<<"La note maximal est:"<<endl;
y=maximum(n[i]);
cout<<y<<endl;
cout<<"La note minimal est:"<<endl;
z=minimum(n[i]);
cout<<z<<endl;
cout<<"La moyenne des notes est:"<<endl;
x=moyenne(a,n);
cout<<x<<endl;
return 0;
}
hmmmm i already finished the code... so i'm gonna let u work a little on fixing your code. then post your new code... I really advice you to read the error statement properly and google it if you don't know what it means.

then i can just give u my code.

take care
__________________
Cheers,
Simon
sayo9394 is offline   Reply With Quote