- #1
AK2
- 39
- 0
Code:
#include <stdio.h>
#define K 10
int array1[K], array2[K];
int *ptr;
int addarrays(int x[],int y[]);
main()
{
int count;
for (count = 0;count < K; count++)
{
puts("Enter numbers into array1");
scanf("%d", array1[count]);
}
for (count = 0;count < K; count++)
{
puts("Enter numbers into array2");
scanf("%d", array2[count]);
}
[B]ptr = addarrays(array1,array2);[/B]
for (count = 0;count < K; count++)
{
printf("%d + %d = %d\n",array1[count], array2[count], *(ptr+count));
}
return 0;
int addarrays(int x[], int y[])
{
int count, total[K];
for(count = 0; count< K; count++)
{
total[count] = array1[countk] = array2[count];
}
return total;
}
i compiled this code in dev c++ ide and i got an error on the bolded line. The purpose of the code is two add two arrays and put the results in a new array and print the three arrays. The function addarrays is meant to return a pointer to the first array element to the calling program. This is where the error lies.