C ++ is a required programming language, not an equation solver.
C ++ executes instructions in the order in which you write them. C ++ does not initialize variables unless it is said. C ++ allows you to use a variable whose value has not been initialized, but when you do this, the result is not specified. Unspecified means that everything can happen, including bad things like making crazy numbers.
Here is a detailed explanation:
double pounds, newtons; pounds = newtons/NEWTONS_PER_POUND; newtons = 10.0;
The first statement declares two variables without initializing them. At the moment, their values ββare not indicated.
The second statement reads the newtons value (which could be anything) and divides it by NEWTONS_PER_POUND . The result (which can be any) is assigned to pounds .
The third statement initializes newtons , but it is too late to affect the calculation just performed.
source share