ok..then
c=++a + ++a + ++a
should give the output c=24
but its c=22.
???

Undefined behavior is the SchrÃ¶dinger's cat of programming. The result of an undefined expression could be anything until you actually run it, and the result you get in practice depends on too many factors to be predictable. Results that aren't predictable and can't be controlled are undesirable, right?

The explanation is only weird for the first time. i.e. ++a + ++a = 14
But if you debug and see the value of a, it will be 7 and after that if u add another ++a to it the answer is 22 and the final value of a is 8 and it increments by 1 for everytime you add ++a

i.e.
++a + ++a = 14 final value of a=7
++a + ++a + ++a = 22 final value of a=8
++a + ++a + ++a + ++a = 31 final value of a=9
++a + ++a + ++a + ++a + ++a = 41 final value of a=10 and so on....

So lets say you add one ++a to to the first expression and you get the result 22 i.e. 14+8=22 and it continues like this.

The reason for making ++a + ++a = 14 is:
Lets say you want to print the value of a and since there are 2 values of a so the makers of 'C' decided to give both the a's the final value i.e. 7 in this case and added them to give 14.

I hope I am able to give some justification to it.

The result of an undefined expression could be anything until you actually run it, and the result you get in practice depends on too many factors to be predictable. Results that aren't predictable and can't be controlled are undesirable, right?

The value cannot be determined with any surety. See this

So here is my problem laid out as simple as I can put it.
I cant combine multiple entities together that have related data but are different
(one database table ...