# (a+i)= i*i;

Page 1 of 1

## 5 Replies - 479 Views - Last Post: 14 May 2013 - 10:46 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=321033&amp;s=db0f24177a801e23f20aafb8de5f7bd0&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 nothingme

Reputation: 0
• Posts: 66
• Joined: 02-November 10

# (a+i)= i*i;

Posted 14 May 2013 - 04:46 AM

```int *a= new int[10];
for int (i = 0; i++; i<=9) {
(a+i)= i*i;
}
```

I was wondering what does this line mean -
```(a+i)= i*i;
```

What is the alternative way to do it?
Is This A Good Question/Topic? 0

## Replies To: (a+i)= i*i;

### #2 oyyou

Reputation: 28
• Posts: 196
• Joined: 26-April 10

## Re: (a+i)= i*i;

Posted 14 May 2013 - 04:52 AM

nothingme, on 14 May 2013 - 04:46 AM, said:

```int *a= new int[10];
for int (i = 0; i++; i<=9) {
(a+i)= i*i;
}
```

I was wondering what does this line mean -
```(a+i)= i*i;
```

What is the alternative way to do it?

a[i] = i*i;

### #3 sepp2k

• D.I.C Lover

Reputation: 2610
• Posts: 4,163
• Joined: 21-June 11

## Re: (a+i)= i*i;

Posted 14 May 2013 - 05:08 AM

It doesn't mean anything. It will cause a compilation error because a+i does not produce an lvalue and thus can't be assigned to.

oyyou, on 14 May 2013 - 01:52 PM, said:

a[i] = i*i;

That would be *(a+i) = i*i;.

• Saucy!

Reputation: 6246
• Posts: 24,014
• Joined: 23-August 08

## Re: (a+i)= i*i;

Posted 14 May 2013 - 12:10 PM

This is completely wrong:

```for int (i = 0; i++; i<=9) {
```

It's for (startConditions; endConditions; increment).

### #5 buffalobill

Reputation: 21
• Posts: 188
• Joined: 08-July 08

## Re: (a+i)= i*i;

Posted 14 May 2013 - 09:41 PM

I think its a recursive type statement (where i appears on both sides of the equation).
It means the same as:
a=i(i-1)//if i=3 a=6.

### #6 jjl

• Engineer

Reputation: 1270
• Posts: 4,998
• Joined: 09-June 09

## Re: (a+i)= i*i;

Posted 14 May 2013 - 10:46 PM

Quote

I think its a recursive type statement (where i appears on both sides of the equation).

That doesn't imply that a function is recursive. A recurrence relation is one that is dependent on the sequence of preceding terms.

i.e.
not recursive
f(x) - x = x * x

recursive
f(x) = x * x + f(x-1)
f(0) = 1

This post has been edited by jjl: 14 May 2013 - 10:46 PM