ARRAY PROBLEMS

Pages: 12
HELP!!!!!!!


program that specifies three one dimensional arrays named current, resistance, and volts. each array should be declared in main() and should be capable of holding 5 double precision numbers. the numbers should be stored in current are {10.62, 7.23, 15.12, 20.15, 9.62} resistance{8.51, 6.58, 7.35, 15.12, 2.05}, calcVolts () . which shoul calculate the elements in the volts array by getting the product of the corresponding elements of current and resistance arrays. then the values of the volts should be displayed within the main()

Last edited on
What have you written so far?
i dont know :( we're asked to write down the codes. :(
can you write down the codes. please?
We don't offer full homework solutions on this site. Make a valid attempt at writing at least something and we can help you from there.
Last edited on
closed account (NyqLy60M)
Here's the calcVolts() function:

1
2
3
4
5
6
7
void calcVolts(double current[5], double resistance[5], double volts[5])
{
	for (int j = 0; j < 5; j++)
	{
		volts[j] = current[j] * resistance[j];
	}
}


You've just got to create the three one-dimensional arrays, call calcVolts with the provided arguments, and use a for loop to output each element inside of volts[].
Last edited on
It's not funny to jokingly give out bad solutions.
closed account (NyqLy60M)
Why don't you enlighten me with a better solution, then?
It is pointless to return any value from the function ;)
closed account (NyqLy60M)
"...then the values of the volts should be displayed within the main()"
*cough* don't give solutions LB means (I think) *uncough*

EDIT: Read the code, figured out what LB meant.
Last edited on
Vemc wrote:
"...then the values of the volts should be displayed within the main()"
You have multiple misconceptions about arrays passed to functions - do some googling ;)
closed account (NyqLy60M)
That's all you had to say, no need to act disrespectful.
I wasn't trying to be disrespectful, there have indeed been people who have jokingly given intentionally bad solutions and it is difficult to determine emotion or genuine-ness on the internet.
Last edited on
closed account (NyqLy60M)
Is that really all that's wrong with it, or should I be using templates?
I'd really appreciate a shove in the right direction.
The OP's specifications are vague but say to use doubles. I don't think templates are appropriate here anyway unless you forced them to only allow floating point types.
It is pointless to return any value from the function ;)

Do you mean that the change happens on volts[j] will be lost when leave the function?
i'm a newbie. we were asked to solved this as a home work and it's so hard because we haven't discussed it yet. so if you could help me, i will do my best to figure out why it came out with that kind of solution . :)) :(
#include<iostream.h>
#include<conio.h>

int main ()
clrscr ();

int calcVolts;
double num [i]={10.62, 7.23, 15.17, 20.15, 9.62};
double num [j]={8.51, 6.58, 7.35, 15.12, 2.05};




is it correct? :D what's next????? im confused ;\
okay :D thanks by the way :)
Pages: 12