I keep getting this error and I can't find the problem:
exam.c: In function ‘main’: exam.c:21:2: warning: passing argument 1 of ‘calculation’ makes pointer from integer without a cast [enabled by default] exam.c:2:5: note: expected ‘int *’ but argument is of type ‘int’ exam.c:21:2: warning: passing argument 2 of ‘calculation’ makes pointer from integer without a cast [enabled by default] exam.c:2:5: note: expected ‘int *’ but argument is of type ‘int’
I tried to change the arrays to pointers, but that did not work either. Here is my code:
#include <stdio.h> int calculation(int arrayOne[50], int arrayTwo[50], int i); int main(void) { int myArray[50]; int myArrayTwo[50]; int i; for(i=0;i<49;i++) { printf("Enter values of arrays: "); scanf("%d", &myArray[i]); printf("Enter second value: "); scanf("%d", &myArrayTwo[i]); if (myArray[i] == 0) { break; } } calculation(myArray[i], myArrayTwo[i], i); } int calculation(int arrayOne[50], int arrayTwo[50], int i) { int total; int j; for (j=0;j<i;j++) { total = arrayOne[j] + arrayTwo[j]; } }
What I am trying to do is create a program which can hold 50 different values and if a user enters 0 for myArray then the program ends. The program passes the values to calculation function and calculation functions calculates the arrays and show the total value.