Help with array Pleaase

How to write a function that receives an integer array along with its length. the function calculates and returns the sum of the squares of all the odd numbers in the array?
is it something like this
#include <iostream>
using namespace std;

void digitArray(int a[], int length, int b);

int main()
{
const int l = 20;
int a[l] = { 0 };
int b;
int j;

cout << "Enter a number with 5-12 digits: ";
cin >> b;

digitArray(a, l, b);

for(j=0;j<l;j++)
cout << a[j];
cout << endl;

system("pause");
return 0;
}

void digitArray(int a[], int length, int b)
{
int i;
for(i=0;i<length;i++)
{
a[i] = (b%10);
b = b/10;
}
}
The array size is a constant integer. I'd usually put the const keyword on the size variable in the function too.


Topic archived. No new replies allowed.