0
votes

Ive got a problem. I cant compile my program even though everything seems fine. It comes up with those errors":1.c:6:5: error: conflicting types for ‘sumaa’ int sumaa(int tab[],int a){ ^~~~~ 1.c:3:5: note: previous declaration of ‘sumaa’ was here int sumaa(int,int); ^~~~~ I dont know why. Here's the code:

#include<stdio.h>

int sumaa(int,int);
int suma(int*,int*);

int sumaa(int tab[],int a){
    int sum = 0;
    for(int i= 0; i<a;i++)
        sum+= tab[i];
    return sum;
}

int suma(int* a,int* b){
    int  suma = 0;
    int* pt;
    for (pt = a; pt != b; pt++)
        suma+=*pt;
    return suma;
}

int main()
{
    int n;
    scanf("%d",&n);
    int tab[n];
    for(int i = 0; i<n;i++){
        scanf("%d",&tab[i]);
    }
    sumaa(tab,n);
    suma(tab,tab+n);
    return 0;
}
1

1 Answers

1
votes

You have to make the first parameter as an array in the prototype.

int sumaa(int*,int);