I can not find the mistakes

1

Someone can help me, this program is giving several errors, but I can not find any. Thanks in advance.

Errors:

  • [Error] can not convert 'int *' to 'int **' for argument '3' to 'int read (int, int, int **)'
  • [Error] invalid conversion from 'int' to 'int *' [-fpermissive]
  • [Error] initializing argument 3 of 'int print (int, int, int *)' [-fpermissive]
  • [Error] invalid conversion from 'int' to 'int *' [-fpermissive]
  • [Error] initializing argument 4 of 'int sum (int, int, int *, int *)' [-fpermissive]
  • [Error] invalid conversion from 'int' to 'int *' [-fpermissive]
  • [Error] initializing argument 3 of 'int major (int, int, int *, int *)' [-fpermissive]
  • [Error] expression list treated as compound expression in initializer [-fpermissive]
  • [Error] ISO C ++ forbids comparison between pointer and integer [-fpermissive]

    #include <iostream>
    #include <string.h>
    #include <sstream>
    #include <cmath>
    using namespace std;
    int leitura(int i, int q_numeros, int *vetor[1000]);
    int impressao(int i, int q_numeros, int vetor[1000]);
    int somatorio(int i, int q_numeros, int *soma, int vetor[1000]);
    int maior(int i, int q_numeros, int vetor[1000], int *max);
    int fimpar(int *impar, int i, int q_numeros, int vetor[1000]);
    int main(){
       int q_numeros, vetor[1000], i, max, soma, impar;
       cout<<"Programa que apartir dos numeros inseridos diz quem são eles, o seu somatorio, qual é o maior e quantos impares foram digitados.";
        cout <<"\nDigite quantidade de numeros a ser inseridos no programa:";
        cin >> q_numeros;
        leitura(i, q_numeros, &vetor[1000]);
        impressao(i, q_numeros, vetor[1000]);
        somatorio( i, q_numeros, &soma,vetor[1000]);
        cout<<"\nSomatorio dos numeros digitados é:"<<soma<<endl;
        maior( i,  q_numeros, vetor[1000], &max);
        cout<<"\nMaior numero é: "<< max<<endl;
        int fimpar (&impar, i, q_numeros, vetor[1000]);
        cout<<"n\A quantidade de numeros impares é: "<< impar<<endl;
        return 0;
    }   
    int leitura(int i, int q_numeros, int *vetor[1000]){
        cout<<"digite os numeros";
        for(i=0; i<q_numeros;i++){
        cin >> *vetor[i];
    }
    return 0;
    }
    
    int impressao(int i, int q_numeros, int vetor[1000]){
        cout << "Numeros digitados foram:\n";
        for(i=0; i<q_numeros;i++)
        {
        cout << vetor[i]<<"\n"<< endl;
        }
    return 0;
    }
    int somatorio(int i, int q_numeros, int *soma, int vetor[1000]){
        for(i=0; i<q_numeros;i++){
            *soma=*soma+vetor[i];
        }
    return 0;
    }
    
    int maior(int i, int q_numeros, int vetor[1000], int *max){
        for(i=0; i<q_numeros;i++) {
        if (max<vetor[i]) {
            *max=vetor[i];
        }
        else{
        }
    }
    return 0;
    }
    int fimpar (int *impar, int i, int q_numeros, int vetor[1000]) {
    
        for(i=0; i<q_numeros;i++){
            if ((vetor[i] % 2) == 0){
            }
            else
            {
                *impar++;
         }
    }
    return 0;
    }
    
  • asked by anonymous 09.06.2014 / 20:51

    1 answer

    1

    Next, in your statement:

    int leitura(int i, int q_numeros, int *vetor[1000]);
    

    Notice that you are asking for an array pointer. The identifier of an array is already a pointer (to the first array address), so in this it may even be considered that you want a pointer pointer.

    In your case I think the best thing would be to do this:

    int leitura(int i, int q_numeros, int vetor[1000]);
    

    and

    leitura(i, q_numeros, vetor);
    

    In this line above, I just passed the name because as I mentioned the name is an array.

    The other errors follow the same logic.

        
    09.06.2014 / 23:05