I can’t find my mistakes

Asked

Viewed 1,103 times

1

Someone can help me, this program is making several mistakes, but I can not find any. I thank you already.

Mistakes:

  1. [Error] cannot Convert 'int*' to 'int**' for argument '3' to 'int reading(int, int, int**)'
  2. [Error] invalid Conversion from 'int' to 'int*' [-fpermissive]
  3. [Error] initializing argument 3 of 'int impressao(int, int*)' [-fpermissive]
  4. [Error] invalid Conversion from 'int' to 'int*' [-fpermissive]
  5. [Error] initializing argument 4 of 'int somatorio(int, int*, int*)' [-fpermissive]
  6. [Error] invalid Conversion from 'int' to 'int*' [-fpermissive]
  7. [Error] initializing argument 3 of 'int maior(int, int*, int*)' [-fpermissive]
  8. [Error] Expression list treated as compound Expression in initializer [-fpermissive]
  9. [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;
    }
    
  • 1

    Can list which errors are appearing?

  • 1

    Whenever you ask a question, be as specific as possible. In this case, you have not reported what errors occur. Recommend visiting these links: http://answall.com/tour. and primarily http://answall.com/questions/how-to-ask-beta

  • Why so many negative votes so fast? The guy is new, the tip was given in the comments. I think they could wait a little, even discourage the boy to supplement the question.

  • @Joaopaulo I did not give -1, but I believe some of them were because the original question (before my edition) was deformed.

  • 1

    Thanks for the help. I will elaborate the next questions better.

  • @Andréfigueiredo In my way of seeing these negative votes (if given immediately) can drive away new users who have not yet learned and also cause experienced users not to click the question to answer it because they think it really doesn’t fit, even if it has already been edited and complemented in the correct way.

  • @Joaopaulo I agree, because there are people who refuse and do not withdraw the vote, when the question became good.

Show 2 more comments

1 answer

1

Next, in his 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 (pro first address of the array), so this can even be considered that you want a pointer.

In your case I think it would be best to do so:

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

and

leitura(i, q_numeros, vetor);

On this line above, I just passed the name as I quoted the name is an array.

The other errors follow the same logic.

  • Thank you, that’s right.

  • 1

    only one correction: int *vetor[1000] does not declare a array pointer, but a array of pointers... which was definitely not what he wanted. Because of operator precedence, an array pointer would be int (*vetor)[1000]. And @Henriquemelo, if the answer solved your problem, mark it as the right answer (under the number of the votes of the answer, there is a green "tick" outlined in which you click to mark that answer)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.