Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between execution and evaluation?

We say that expresssions "evaluate" values and statement orders computer to "execute". But to me it seems like same terminology. What is the difference between execution and evaluation in C?

like image 916
Jin Avatar asked Jul 28 '16 12:07

Jin


1 Answers

It's just a matter of linguistics. Expressions are evaluated, statements are executed. In both cases we can say that "something gets done", and I wouldn't worry too much about the difference.

To clarify: roughly, a statement is a line of code, and an expression is what you can find between brackets in an if() or while(), or on the right side of an equal sign.

For example, int x = 2 + 3; is a statement that declares a variable x and assigns to it the result of the expression 2 + 3, that is, 5.

like image 151
Fabio says Reinstate Monica Avatar answered Sep 26 '22 03:09

Fabio says Reinstate Monica