XOR and multiplication

Hi

my code looks like this

``````int reading[10];
int letzterZustand[10];
int ereignis;

for(int i = 0; i < 10; i++) {
ereignis = (reading[i] ^ letzterZustand[i]) * i;
}
``````

reading and letzterZustand are compared and should be multiplied by i
But that doesn’t work. ereignis is always 0.

If I write:

``````    ereignis = (reading[i] ^ letzterZustand[i]);
``````

I get 1 on difference of reading and letzterZustand as expectet

If I write:

``````    ereignis = (reading[i] ^ letzterZustand[i]) * 5;
``````

I get 5 on difference of reading and letzterZustand as expectet

But if i set i = 5

``````    ereignis = (reading[i] ^ letzterZustand[i]) * i;
``````

gives me 0.

How to solve the Problem?
Thanks
Hans

my code looks like this

Considering that much of it is in italics because you did not Read this before posting a programming question and follow the instructions on posting code I find that quite funny

How can you tell?
Your code never does anything with ereignis, not even a Serial.println(ereignis).
So obviously this isn’t your real code, and neither does it demonstrate the problem.

With the code that you showed of course ereignis is zero. Why ereignis is zero in the other case remains a mystery because you showed neither the code nor the values.

hansreil:
But if i set i = 5

``````    ereignis = (reading[i] ^ letzterZustand[i]) * i;
``````

gives me 0.

you mean

``````    ereignis = (reading[5] ^ letzterZustand[5]) * 5;
``````

what are the values of the arrays?

Found the problem. The solution was
#include "Arduino.h"

Thanks UKHeliBob for your help.
Hans