Click here to Skip to main content
12,697,076 members (24,366 online)
Click here to Skip to main content

Tagged as

Stats

890 views
Posted

Im getting a different result than the compiler when tracing array excercise

, 10 Nov 2012 CPOL
when i trace the code im getting 1,3,5,7 for the answer but the compiler prints 1,3,6,10im having trouble understanding how this happens could anyone explain int [] a= new int[5]; // create arrayfor (int i =1; i<=4; i++) { a[i]=a[i-1]+i; System.out.print(a[i]+" ");}

Revisions


  

Compare Revision Minor Date Status Editor
2 - publicly available No 10-Nov-12 9:23 Available TorstenH.
Updates in content.
1 No 10-Nov-12 8:32 Available diego14567

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

diego14567
United States United States
No Biography provided

You may also be interested in...

Pro
Pro
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170118.1 | Last Updated 10 Nov 2012
Article Copyright 2012 by diego14567
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid