-2
#include <iostream>
#include<stdio.h>
#include <stdlib.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
float media (int n, float *vetor[]){
float m = 0, soma = 0;
//fazendo soma do vetor
for (int i = 0; i < n; i++){
soma = soma + vetor[i];
}
//calcular media
m = soma / n;
//retornar
return m;
}
int main(int argc, char** argv) {
int n;
float vetor[n];
float mediaFinal;
//Leitura das notas
cout << "Informe o tamanho do vetor: ";
cin >> n;
cout << "Preencha o vetor com " << n << " inteiros: ";
for (int i = 0; i < n; i++) {
cin >> vetor[n];
}
//Chamado do metodo
mediaFinal = media(n, vetor);
cout << "Media = " << mediaFinal;
return 0;
}
When compiling at line 13 it displays the error "invalid operands of types 'float' and 'float*' to Binary 'Operator+'", I don’t know how to resolve.
Please clarify your problem or provide additional details in order to highlight exactly what you need. The way it’s written these days it’s hard to tell exactly what you’re asking.
–
I already tidied up I didn’t know how to work the platform
– Henrique Ianni Silva