+ 2
How does a program know to add two values when '+' sign is put in between them?
int a=2;int b=3; a+b= int c; then c is 5 how does a program identify the operator and does the function related to that sign?
5 Respuestas
+ 15
a and b both are integer here not strings. That's why '+' sign add the two values instead of concating them.
a="2"; b="3"; c=a+b; // c=23
because a and b both are strings here.
+ 9
One more thing, these things are also common in PHP and JavaScript
+ 2
For compiled program : they are transformed in binary files so the + is changed by the binary message of the addition for the processor.
For interpreted programs : quit the same but it is the interpreter which read the + that run its functionality which was transformed in the binary message for addition.
+ 1
thanks for correcting my mistake
0
what if both are integers?