Im getting a different result than the compiler when tracing array excercise
Revision 2
when i trace the code im getting 1,3,5,7 for the answer but the compiler prints 1,3,6,10
im having trouble understanding how this happens could anyone explain
int [] a= new int[5];
for (int i =1; i<=4; i++)
{
a[i]=a[i-1]+i;
System.out.print(a[i]+" ");
}
Posted 10-Nov-12 12:32pm
by
diego14567.