In this tutorial you would learn about keywords and identifiers in C language. Which is basic concept of C language syntax.
C Keywords
Keywords are predefined and reserved words for C language. Compiler knows the meaning of these words.
All keywords are written in lowercase.
Here is list of all keywords in C.
auto | double | int | struct |
break | else | long | switch |
case | enum | register | typedef |
char | extern | return | union |
continue | for | signed | void |
do | if | static | while |
default | goto | sizeof | volatile |
const | float | short | unsigned |
As mentioned earlier, all these keywords has some associated meaning with then which instructs the compiler what you want to do/convey to compiler.
C Identifiers
Identifiers are name given to C constructs which are declared using C keywords.
Rules to write C identifiers
- It can contain only alphanumberic (a-z,A-Z,0-9) and underscore ( _ ) characters only
Below are some valid identifier names.- number
- _money
- _student_
- car1234
- home321_
- It can't start with digit.
i.e. '9number' is invalid identifier - Identifiers are case sensitives.
i.e. 'number' and 'Number' are two different identifiers
Example
int number;
Here we have declared variable 'number' of type integer.
'int' is keyword here whereas 'number' is identifier.
long value;
Here we have declared variable 'value' of type long integer.
'long' is keyword here whereas 'value' is identifier.
char ch10;
Here we have declared variable 'ch10' of type character.
'char' is keyword here whereas 'ch10' is identifier.
Quiz
We recommend you to take a quiz on C Keywords and Identifiers to test and improve your understanding.