#include <stdio.h>
#define N 40
void sum(int*p, int n, int d[])
{
  int i;
  *p = 0;
  for(i = 0; i < n; ++i)
     *p = *p + d[i];
}
int main()
{
   int i;
   int accum = 0;
   int data[N];
   for(i = 0; i < N; ++i)

      data[i] = i;

    sum(&accum, N, data);
    printf("sum is %d\n", accum);
return 0;
}

So what have you tried so far?

My guess is that if you try to compile this with a C++ compiler, it will work just fine. So, why do you need to convert it further?

(btw, I have my suspicions, I'm no fool)

In any case, you need to show that you tried something. We will not just do a "conversion" to C++ for you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.