arrays

how can I Create an integer array c that holds the element-wise product of the two arrays?

1
2
3
4
5
6
7
8
9
#include <iostream>
using namespace std;
int main()
{
    int a [52]={0,1,2,3,4,5};
    int b [52]={0,1,2,3,4,5};
    int c [];
            
}

The c that you have now has no elements. You have to state the size right there.

I presume that you don't expect:
std::transform( std::begin(a), std::end(a), std::begin(b), std::begin(c), std::multiplies<int>() );
1
2
3
4
5
6
7
8
9
#include <iostream>
using namespace std;
int main()
{
    int a [52]={0,1,2,3,4,5};
    int b [52]={0,1,2,3,4,5};
    int c [52];
            
}


so how would I multiply each member of a with b ( 0*0 , 1*1 ... ) in array c?
Last edited on
If you had looked up the reference documentation for transform, you would have two hints. Perhaps for is an easier hint?
Thank you! But I've solved it and I have put a check on the thread!

Thank you again
Topic archived. No new replies allowed.