int sum; sum = 42 - 12 ;
Yes, the statements are syntactically correct.
The syntax of a programming language says what programs look like. It is the grammar of how to arrange the symbols. The semantics of a programming language says what the program does as it executes. It says what the symbols mean. This page explains the semantics of the assignment statement.
An assignment statement does its work in two steps:
total = 3 + 5;
It does not matter if
total already has a number
Step 2 will replace whatever is already in
points = 23;
What happens FIRST when the following statement executes?
value = 2*3 ;