Haruna Hussein
last month
Harunacountry asked

Why are variable names like salary, age, and number1 considered good, while others like s, aGekv2, and nbr1 considered bad, even though they are all valid variable names?

Kelish Rai
Expert
2 weeks ago
Kelish Rai answered

I agree that all the names listed in the good and bad variable name examples are valid options for C++ programs.

However, when defining good variable names, the goal is to choose names that are both easy to understand and easy to work with.

For example, it’s much clearer to understand a variable named salary than one named s. Similarly, age is much easier to use and comprehend than something like aGekv2, which doesn’t really convey any meaning.

In short, good variable names should be straightforward, intuitive, and consistent.

C++
This question was asked as part of the Learn C++ Basics course.