In this chapter, we will learn about keywords and identifiers in c programming languages because these are the essential parts of a program. So let’s get started
Let’s discuss about C Keywords
As we know that c programming has rich set of library functions inside header files. Each keyword has specific meaning or nature which is defined in library/header files.
Keywords are predefined and/or reserved words used in any programming languages and they have special nature for compiler. Keywords can’t be used an user-defined identifier such as variable, function, array etc. For example:-
int price; // here int is a keyword that shows price is an varialbe of int type
All the keywords in c programming language should be written in lowercase because its a case sensitive language. For example: int is reserved keyword so you can’t write in INT.
Please find the list of keywords allowed in ANSI (American National Standards Institute) C.
Let’s discuss about C Identifiers
Identifiers is used defined name to entity like variables, functions, structures, array etc.
We can’t define two entity with same identifier name. They should have given a unique name so compiler can identify while execution of program. For example:
int price; // here int is keyword and price is an identifier of integer type double cost; // here double is keyword and cost is an identifier of double type
NOTE: each time when you define a new identifier, it should be different from keywords otherwise you compiler will confuse and will give you an error. So make sure to not use double as an identifier because double is an reserved keyword.
Some rules of defining identifiers
- Name of identifier should start with a letter or an underscore.
- A valid identifier name can have lowercase and/or uppercase letters, digits and underscore. For example: int price1, int PRICE, int price_1, double price123_ etc. These are valid examples
- We cannot use keyword as identifier. For example: int double, double while etc. These are the invalid examples. So make sure your identifier name shouldn’t match with keyword.
Giving meaningful name for identifier make sense to create readable program.
Let’s discuss about Character set
A valid character set is consists of set of alphabets, letters and special characters.
Uppercase: A B C ................................... X Y Z Lowercase: a b c ...................................... x y z
C allows us to write variables and functions name with combination of uppercase and lowercase alphabets.
0 1 2 3 4 5 6 7 8 9
White space Characters
Blank space, newline, horizontal tab, carriage return and form feed.