Why we cannot use keywords as a variable

Asked By 0 points N/A Posted on -
qa-featured

HELLO!

I have a question in my mind; can anybody please help me? When we design code, if we use KEYWORDS as a variable for our own use in code an ERROR is usually displayed that "IT IS A RESERVED WORD". Why can't we use a keyword as a variable? Please explain any solid reason behind it.

SHARE
Best Answer by JaySoftCenter
Answered By 0 points N/A #85968

Why we cannot use keywords as a variable

qa-featured

Hello,

  • Reserve words have special meaning within the programming languages. They are special words use to identify the data types in language that supports the system, which identify the blocks and loops. They are also called keywords.
  • So, when you use reserve keyword as a variable the compiler gets confused and treats that variable as a keyword. Their function is already defined in the system library, and the compiler behaves as though it is in the library. So, due to this reason, reserve words are not used as variables as this would create a problem to both the user (as goes through the program he can get confused) and also to the compiler.

Regards,

Charles.

Best Answer
Best Answer
Answered By 0 points N/A #85969

Why we cannot use keywords as a variable

qa-featured

Hi Good Day,

The reason we cannot use it to declare a variable from the C programming is because the keywords are defined in the C language for specific purposes. If we declare a variable with the same name, the compiler would not know if you are trying to use a variable or that you are trying to perform an action with that keyword. That keyword cannot be used as a variable name.

Hope this will help to solve your problem.

Login/Register to Answer

Related Questions