educative.io

First time learning literals

So I just started learning Literals and I am not quite sure I understood it correctly. It was written, “Literals are explicit values in the program.”. Basically these are the same as const as in previous versions of C++…??

Hi Ritvik!
Can you please send us the course name or link so we can figure out in which lesson your are facing the issue.

Hope you have an amazing learning experience on Educative!

a literal is a value that represents a fixed constant value of a basic data type such as int, float, double, bool, char, etc. The value of a literal is known at compile-time and cannot be changed during program execution.

For example, the integer literal “10” represents the fixed value of 10, and the boolean literal “true” represents the fixed value of true.

literals and constants in C++ both represent fixed values that cannot be modified at run-time, but they differ in how they are defined and used in the program. Literals are fixed values directly used in the code, while constants are named identifiers that represent fixed values.