#include "stdafx.h" #include using namespace std; // C = A + B void vectorAdd(const int A[], const int B[], int C[]); // Preferred method // all these valid too in terms of syntax, but not recommended //void vectorAdd(int A[10], int B[10], int C[10]); //void vectorAdd(int *A, int *B, int *C); //void vectorAdd(int A[5], int *B, int *C); //void vectorAdd(int A[5], int *B, int C[]); void vectorAdd(const int A[10], const int B[10], int C[10]) { for (int i = 0; i < 10; i++) C[i] = A[i] + B[i]; } int main() { int P[10] = { 1 }, Q[10] = { 2 }, R[10]; // the next 3 lines remind you that P is treated as int * (not 100% the same thing, but // for our purposes we can ignore the difference for now). // int *ip; // ip = P; // ip = &P[0]; // R = P + Q vectorAdd(P, Q, R); return 0; }