Lets say you use a variable named abcd in your function. And a variable named abcb in a for loop inside the same function. But because reasons you mistakenly use abcd inside that loop and modify the wrong variable, so that your code sometimes doesnt work properly.
It’s to prevent mistakes like that.
A similar thing is to use const when the variable is not modified.
I’m not a CS major but why exactly does having a variable or parameter that’s not used in C, C# and C++ throw a warning
Lets say you use a variable named abcd in your function. And a variable named abcb in a for loop inside the same function. But because reasons you mistakenly use abcd inside that loop and modify the wrong variable, so that your code sometimes doesnt work properly.
It’s to prevent mistakes like that.
A similar thing is to use const when the variable is not modified.
Because it’s code that literally doesn’t do anything. Some languages won’t even let you compile without special instructions.