Forums Register Login

loops and arrays

+Pie Number of slices to send: Send
Hello, everyone!
I have some problems with this code.
The idea is to make a code which allows two add two numbers and display the results.
But it doen't work:(
Please, explain me why.
+Pie Number of slices to send: Send
Saying "it doesn't work" is not the best way to get responses from people.  Instead, post the error message.

I went ahead and run the code and I got this error:

So an index to an array is out of bounds (too large or too small).  Indexes start at zero, to an array of size 2 will have indexes 0 and 1.  Can you see what's wrong with the inner for-loop?  Can you predict what will happen with the outer for-loop?
+Pie Number of slices to send: Send
 

Knute Snortum wrote:Saying "it doesn't work" is not the best way to get responses from people.  Instead, post the error message.

I went ahead and run the code and I got this error:

So an index to an array is out of bounds (too large or too small).  Indexes start at zero, to an array of size 2 will have indexes 0 and 1.  Can you see what's wrong with the inner for-loop?  Can you predict what will happen with the outer for-loop?


Thank you for advice, it was my first post.
+Pie Number of slices to send: Send
...and welcome to the Ranch
+Pie Number of slices to send: Send
 

Sabina Belyaeva wrote:Thank you for advice, it was my first post.


But what if someone hadn't seen that post?
When it is used for evil, then watch out! When it is used for good, then things are much nicer. Like this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 326 times.
Similar Threads
Problem with declaring dimensions of a general array? (edited)
nested for loop
problem with java code
can any one explain Two -Dimensional Arrays (code)
14-Based Numbering System
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 04:26:46.