help in array!

0 Adesoji timilehin · September 16, 2015
hello guys please am trying to write a code to calculate equivalent parallel resistance of a circuit, am using an array to store my values for the resistor and it worked well  but when i wanted to divide each values in the array by 1 and add it all together but it's not working 

Post a Reply

Replies

Oldest  Newest  Rating
0 Arend Peter Castelein · September 18, 2015
As Alan said seeing you code as well as the error would be helpful. Anyway this is how I would do it (I'm not sure why you'd want to divide by 1 but I put it in there anyway)

int n = 50;
int arr[n];
int sum = 0;
for(int i = 0; i < n; i++){
arr[n] /= 1;
sum += arr[n];
}
+1 Alan Masimba Walker · September 17, 2015
Could you please post an example of your code and I'll see what's the problem!
  • 1

C++

107,004 followers
About

Used in many types of software including music players, video games, and many large scale applications.

Links
Moderators
Bucky Roberts Administrator