Search:

Type: Posts; User: Cornix

Search: Search took 0.12 seconds.

  1. Re: Print variable which only exists within for loop?

    There are still a few small problems.

    1) you should change your for loop to run until the end of the array instead of hardcoding a value:

    // this is bad
    for (int i=0; i<10; i++) {


    // this...
  2. Re: Print variable which only exists within for loop?

    What you want to do is sum up the elements of the array.
    Think about it without writing code. Try to write the steps down one by one on a piece of paper.
    You have a list of numbers. You can always...
  3. Re: Print variable which only exists within for loop?

    By declaring it outside of the loop.

    By the way, I dont understand your calculation within the loop. You add all numbers 10 times?
Results 1 to 3 of 3