[try Beta version]
Not logged in

 
ARRAY PROBLEMS

Pages: 12
Jan 14, 2014 at 3:49am
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 Jan 14, 2014 at 3:57am
Jan 14, 2014 at 3:50am
What have you written so far?
Jan 14, 2014 at 3:55am
i dont know :( we're asked to write down the codes. :(
Jan 14, 2014 at 3:58am
can you write down the codes. please?
Jan 14, 2014 at 4:11am
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 Jan 14, 2014 at 4:11am
Jan 14, 2014 at 4:29am
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 Jan 14, 2014 at 7:00am
Jan 14, 2014 at 5:07am
It's not funny to jokingly give out bad solutions.
Jan 14, 2014 at 5:13am
closed account (NyqLy60M)
Why don't you enlighten me with a better solution, then?
Jan 14, 2014 at 5:41am
It is pointless to return any value from the function ;)
Jan 14, 2014 at 5:43am
closed account (NyqLy60M)
"...then the values of the volts should be displayed within the main()"
Jan 14, 2014 at 5:46am
*cough* don't give solutions LB means (I think) *uncough*

EDIT: Read the code, figured out what LB meant.
Last edited on Jan 14, 2014 at 5:49am
Jan 14, 2014 at 5:48am
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 ;)
Jan 14, 2014 at 5:51am
closed account (NyqLy60M)
That's all you had to say, no need to act disrespectful.
Jan 14, 2014 at 6:20am
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 Jan 14, 2014 at 6:21am
Jan 14, 2014 at 7:04am
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.
Jan 14, 2014 at 7:37am
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.
Jan 14, 2014 at 9:02am
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?
Jan 14, 2014 at 9:44am
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 . :)) :(
Jan 14, 2014 at 9:49am
#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 ;\
Jan 14, 2014 at 10:23am
okay :D thanks by the way :)
Pages: 12