What optimizations will take place depends on the compiler. In your case, both C and C++ compilers will normally have enough information to optimize your source code into identical machine code. In other words, it doesn't really depend much on what is literal and what is constant in this code.
Having said that, the meaning of the terms literal and constant are significantly different in C and C++ (and you tagged your question C and C++ at the same time).
- In C
60
and 3.0f
are constants, but y
is not a constant. You can call y
a const-qualified variable if you wish, but it is not a constant in C terminology, in a sense that a single y
is not a constant expression in C.
As for literals, in C language the term literal only applies to string literals (and also compound literals in C99), i.e. there are no literals in your code at all.
- In C++,
60
and 3.0.f
are literals, which form constant expressions (integral and floating -point respectively). y
is also a constant of int
type, in a sense that a single y
is a constant expression in C++.
The situation when you might notice the difference has nothing to do with optimizations, but rather with the way the languages are defined. For example, using the above y
in a file-scope array type declaration is legal in C++, but not in C
typedef int int_array[y]; /* OK in C++, ERROR in C */