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);

cout << a[j];
cout << endl;

return 0;

void digitArray(int a[], int length, int b)
int 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.