About Lesson
- const: Constants are variables whose value cannot be changed once initialized. They are declared using the
const
keyword. - signed: By default, integral data types (such as int and char) are signed, meaning they can represent both positive and negative numbers.
- unsigned: Using the
unsigned
keyword with integral data types restricts them to represent only non-negative values (zero and positive numbers).
const int MAX_SIZE = 100; // Declaration of a constant variable signed int temperature = -10; // Declaration of a signed integer unsigned int count = 50; // Declaration of an unsigned integer
In the above code, MAX_SIZE
is a constant with a value of 100, temperature
is a signed integer initialized to -10, and count
is an unsigned integer initialized to 50.
Understanding these basic concepts of declaring and initializing variables, fundamental data types, and type modifiers lays the groundwork for writing C++ programs that manipulate data effectively and accurately.
Join the conversation