#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
void conceito (int, int [], float []);
int main(int argc, char** argv) {
int al[200];
int quant,i;
float media[200];
char res;
do{
cout<<"matricula do aluno: ";
cin>>al[i];
cout<<"Media final do aluno: ";
cin>>media[i];
cout<<"novos dados? s/n: ";
cin>>res;
}
while( res=='s'||res=='S');
quant=i;
cout<<" ALUNO**********CATEGORIA"<<endl;
for (int i=0;i<quant;i++){
conceito(quant,al[i],media[i]);
}
return 0;
}
void conceito(int quant, int al[], float m[]){
for (int k=0; k<quant; k++){
if (m[k]<5 && m[k]>0)
cout<<"aluno "<<al[k]<<": "<<"D"<<endl;
else if (m[k]<7)
cout<<"aluno "<<al[k]<<": "<<"C"<<endl;
else if (m[k]<9)
cout<<"aluno "<<al[k]<<": "<<"B"<<endl;
else if (m[k]<=10)
cout<<"aluno "<<al[k]<<": "<<"A"<<endl;
}
}
#include <iostream>
usingnamespace std;
/* run this program using the console pauser or add your own
getch, system("pause") or input loop */
void conceito (int, int [], float []);
int main(int argc, char** argv) {
int al[200];
int quant,i;
float media[200];
char res;
do{
cout<<"matricula do aluno: ";
cin>>al[i];
cout<<"Media final do aluno: ";
cin>>media[i];
cout<<"novos dados? s/n: ";
cin>>res;
}
while( res=='s'||res=='S');
quant=i;
cout<<" ALUNO**********CATEGORIA"<<endl;
for (int i=0;i<quant;i++){
conceito(quant,al[i],media[i]);
}
return 0;
}
void conceito(int quant, int al[], float m[]){
for (int k=0; k<quant; k++){
if (m[k]<5 && m[k]>0)
cout<<"aluno "<<al[k]<<": "<<"D"<<endl;
elseif (m[k]<7)
cout<<"aluno "<<al[k]<<": "<<"C"<<endl;
elseif (m[k]<9)
cout<<"aluno "<<al[k]<<": "<<"B"<<endl;
elseif (m[k]<=10)
cout<<"aluno "<<al[k]<<": "<<"A"<<endl;
}
}
A compiler writes:
In function 'int main(int, char**)':
23:24: error: invalid conversion from 'int' to 'int*' [-fpermissive]
23:34: error: cannot convert 'float' to 'float*' for argument '3' to 'void conceito(int, int*, float*)'
The "23:" refers to line 23. Your compiler might say things differently, but it should also tell which lines it does not understand.
Line 23 has: conceito( quant, al[i], media[i] );
Two errors:
invalid conversion from 'int' to 'int*'
The second parameter of conceito() has to be int*. You wrote int[], which is an alias for int*.
The argument that you call the function with is al[i]. The al is array of int and therefore element al[i] is int, not a pointer.
cannot convert 'float' to 'float*' for argument '3'
conceito( quant, al[i], media[i] );
Again, the media is array of float, the element media[i] is float, but the function expects float[].
There is more:
You declare variable i on line 8. What it its initial value?
Do you change the i anywhere?