![]() |
Arrays
Hello, I am to write a program that will send three one dimensional arrays to a function. Two of the arrays have 10 values and one has room set aside for 10 values to be placed into it. The function will take the corresponding elements from each array,multiply them together and put the result into the array with space for 10 values. I am having a hard time figuring out how I can get them to multiply each element and then place them into the array. My guess would be a for loop, or maybe a couple of for loops. Any help appreciated.
Code:
#include<iostream> |
Re: Arrays
Pass them in as parameters:
Code:
void calc_volts(double *volts,double *current,double *resistance);calc_volts() doesn't need to return anything but it will need to take the three arrays as parameters/arguments. |
Re: Arrays
Quote:
|
Re: Arrays
When you modify volts[n] in the array, because you have passed a pointer to the array you're directly modifying the array volts[] in main itself.
For example: Code:
void func(int *y) |
Re: Arrays
Quote:
|
| All times are GMT +5.5. The time now is 23:38. |