Keywords and Identifiers in C Programming

In this post, you will read about Keywords and Identifiers in C Programming. Keywords and identifiers are both important parts of the syntax of C programs.

Keywords and Identifiers in C Programming

Keywords in C – What is C Keywords?

Like the words “laughing, crying, running” already have a meaning and therefore we do not use these words for any other work, just like keywords are in programming.

Keywords are such reserved words which already have specific meaning in C programming or should I say that C programming keywords can be used only for predefined function (work).

Now as you have understood that the meaning and use of C keywords is already fixed, so you cannot use the keywords for any other work.

There are 32 keywords in C programming language and C keywords are always written in lowercase. Below is a list of all 32 keywords.

Keywords and Identifiers in C Programming

autobreakcasecontinue
dodefaultconstdouble
elseenumexternfor
ifgotofloatint
longregistercharsigned
staticsizeofshortstruct
switchtypedefunionvoid
whilevolatilereturnunsigned
Keywords and Identifiers in C Programming

Keywords and Identifiers in C Programming

Identifiers in C – What is C Identifiers?

Everything around us has a name, whether it is a person or some thing. If a person or thing does not have a name, then it will be difficult to identify it, so it is necessary to have a name.

One such C program has many elements such as variables, constants, functions, array etc. And all of them also have a name and we call their names as identifiers.

If understood in simple words, the names given to variables, constants, functions and user-defined data types in C language are called identifiers and with the help of these identifiers (names), the programmer and compiler can identify (call) these elements. does.

In programming, these identifiers (names) are defined with some set of rules. If you do not follow the C identifiers rules, then there may be errors show in your program.

You can also read: Comments in C Programming

Keywords and Identifiers in C Programming

Rules for an Identifiers

Just like two children in the same family do not have the same name, in the same way, in a C program, 2 elements such as 2 variables cannot have the same identifier (name), ie identifiers should be unique.

Only alphanumeric characters ( a-z , A-Z , 0-9) and underscore ( _ ) can be used in C identifiers. You cannot use special characters ( !, @, #, etc.) in C identifiers.

The beginning of C identifiers i.e. the first character can be only with alphabet( a-z , A-Z ) or underscore ( _ ) i.e. you cannot start C identifier with number ( 0-9). Apart from this, keep this rule in mind that space is not allowed in C identifiers.

C programming is case sensitive language and hence num, Num and NUM will be considered as three different identifiers. Apart from this, take special care that you cannot use keywords in C identifier.

Keywords and Identifiers in C Programming

Some examples of Invalid Identifiers

  • int – This is a keyword, so you cannot use it as an identifier.
  • 2num – Identifier should start with alphabet or underscore ‘ _ ‘ symbol only.
  • f@num – Special symbol is not allowed in Identifier.
  • first num – Space is not allowed in the identifier.

Keywords and Identifiers in C Programming

My Personal Suggestion for C Identifiers

It is said that “name is a big thing”, so we name everything very carefully, but some programmers forget this thing while naming C program elements (variable, function, array etc.).

What I mean to say is that whenever you want to specify a variable, function, array etc. Assign an identifier to it, then take care of its use, that is, for what purpose those elements are being used in your program.

For example, if you want to hold someone’s age as a value in a variable, then you will keep the name of that variable as age, then it will be considered a good programming practice.

Variable, function, array, structure etc. in C program. You also have the advantage of giving a meaningful identifier that your code is easily understood by any other programmer.

If you also make changes in your code after a long time, then you will also find it easier to understand your code.

Variable, function, array, structure etc. in C program. You also have the advantage of giving a meaningful identifier that your code is easily understood by any other programmer.

If you also make changes in your code after a long time, then you will also find it easier to understand your code.

What is the difference between C Keywords and Identifiers?

C Keywords

  • Keywords are predefined reserved words in C language.
  • Keywords are only in lowercase.
  • Keywords contain only alphabetical characters.
  • C Keywords Examples: for, struct, int

C Identifiers

  • Identifiers are variables, functions etc. in C language. are user defined names.
  • Identifiers can be lowercase, uppercase or both.
  • Identifiers consist of alphanumeric characters and underscores.
  • C Identifiers Examples: num, ch, height

Keywords and Identifiers in C Programming

I hope that you have liked this post. If you liked the post, then please share it with your friends and relatives and you can send your suggestion in the comment box below or email me at praveen171086@gmail.com.

You can also visit my Hindi YouTube Channel.

Leave a Comment