When to use variables in C++

I was doing a lesson in the C++ course and during one of the exercises I had used an integer to compare with the users input but when I watched the solution Mosh had used a variable instead which made me wonder, when is it better practice to use a variable and when is it better practice to just use a plain number. Thanks lads.

Well, I searched about it on internet and I found that when you don’t need to convey additional context then you can use plain numbers, similarly when you have to change value multiple time within space then you have to use variable in C++.

Alright, that makes pretty good but sense, I didn’t want to be overusing variables and making my scripts unintelligible. Thanks mate, have a good one. :+1: