Docsity

keyword and Identifiers in C programming, Summaries of Computer science

Partial preview of the text

Download keyword and Identifiers in C programming and more Summaries Computer science in PDF only on Docsity!

2026 Edition

Keywords & Identifiers

2026 Edition

Welcome to Module 3

In the 'C' programming language, keywords and modifiers are important elements used to define the structure, meaning, and behavior of a program. Keywords are reserved words that have a predefined meaning in 'C’. They cannot be used as names of variables, functions or other user defined identifiers. Examples include int, if, return, while and void. An identifier in ‘C’ is a name given to program elements such as variables, functions, arrays, structures, and other user defined entities. Understanding keywords and identifiers is essential for declaring variables correctly and controlling program flow. In this module we will learn

  1. keywords in 'C'
  2. Rules and characteristics of keywords
  3. Types of keywords
  4. Identifiers in ‘C’
  5. Rules of Identifiers
  6. Examples of keywords and identifiers in ‘C‘
  7. Linkage process
  8. Comparison between keywords and identifiers.

2026 Edition

S.N. KEYWORDS MEANING

1. auto Used to define automatic storage class

2. break Used to terminate loop and switch statements

3. case Used to represent a case(options) in switch statement

4. char Used to define a character data type

5. const Used to define a constant variable

6. continue Used to skip a process in loop and pass control to the beginning of the

loop

7. default Used to represent a default case in switch statement

8. do Used to define a block in a do-while loop

9. double Used to define a floating double datatype

10. else Used as a fallback statement in if-else statement for a falsy condition

11. enum Used to define enumerated data type

12. extern Used to extend variable or function to another program files

13. float Used to define a float data type

14. for Used to define a for-loop statement block

15. goto Used to jump statement in loop block

2026 Edition

SN. KEYWORDS MEANING

16. if Used to define a conditional if-else statement

17. int Used to define an integer variable

18. long Used to modify a basic data type

19. register Used to define register CPU variable

20. return Used to terminate function execution and return value to the calling

function

21. short Used to modify a basic data type

22. signed Used to modify a basic data type

23. sizeof Used to ascertain the size of a variable type

24. static Used to define static variable

25. struct Used to define structure object

26. switch Used to define switch-case statement

27. typydef Used to define a temporary name for data type

28. union Used to combine different data type sharing the same memory space

29. unsigned Used to modify a basic data type

30. void Means Nothing - pass as a parameter and return value of a function

31. volatile Used to define a volatile variable object

32. while Used to define a while-loop statement

Rules for Naming Identifiers in 'C' 2026 Edition

There are specific rules for naming the identifiers in 'C' language.

  • Do not use any keyword as an identifier. •All the identifiers should have a unique name in the same scope. •Identifiers can not start with a digit. •The first character of an identifier should always start with an alphabet or underscore , and then it can be followed by any of the characters, digit, or underscore. •The special characters such as '*','#','@','$' are not allowed within an identifier. •All the identifiers are case sensitive means the identifiers "hello“ , "Hello“ and “HELLO” will be treated differently. However, all the three names are identical, but one has a lowercase alphabet, second one has mixed case alphabet and the last one has uppercase alphabet. •Length of an identifier should not exceed 31 characters. •Any blank spaces or commas are not allowed within an identifier.

Valid Identifiers 2026 Edition

The valid identifiers in 'C' are those identifiers that follow every single rule of the naming convention of identifiers. Examples of Valid 'C' identifier

  • length - It contains only lowercase alphabets.
  • total_sum - It contains only '_' as a special character.
  • _size - It starts with an underscore '_'. *
  • len_ - Contains lowercase alphabets and an underscore.
  • num1 - Here, the numeric digit comes at the end.
  • num_2 - It starts with lowercase, then underscore and ends with a digit.

2026 Edition

Types of Identifiers

There are two types of identifiers in 'C' language. •Internal identifier •External identifier Internal identifier •Internal identifiers are the ones that are not used in any of the external link processes. •Internal identifiers are also known as internal names. •The internal identifier can be a local variable. It has at most 31 significant characters. •Some of the internal identifiers are local variables, static global variables and static functions. External identifier •External identifiers are the ones that are used in an external link process. •These identifiers are also known as external names ; include function names and global variable names that are shared between source files. •Some of the external identifiers are global variables and standard functions. •It has at least 63 significant characters with case sensitivity.

2026 Edition

Linkage process

•Linkage in ‘C’ determines whether an identifier(such as a variable or a function) refers to the same entity across different scopes or source files. •There are three types of linkage in ‘C’ - No linkage, internal linkage and external linkage.

  • No linkage - The identifier is unique to its scope. Example local variables inside a function.
  • Internal linkage - The identifier can be accessed only within the same source file. In other words, only in the scope of a translation unit. It is usually created using the static keyword at file scope.
  • External Linkage – The identifier can be accessed from the other source files. It refers to a whole program that combines all the translation units. Global variables and functions generally have external linkage. •Pathway of Linkage Process •Source Files Preprocessing Compilation Object Files Linking Executable Files •In External Linkage Process the compiler generates a translation unit for an implementation file (.c, .cpp, etc). Which is a combination of both implemented file and all the header files included in it.