C Language keywords - What is keywords in C Language - How many keywords in C language - Keywords - C language mein keywords kya hote hai

What is keywords in C Language?

In the C programming language, "keywords" refer to reserved words that have specific meanings and functionalities within the language. These words are part of the language's syntax and cannot be used as identifiers (such as variable names, function names, etc.) by the programmer. Keywords are used to define the structure, control flow, data types, and behavior of the program.

Here are some examples of C keywords:

1. Data Types: These keywords define the type of data that a variable can hold.

  • int, char, float, double: Define integer, character, floating-point, and double-precision floating-point data types.
  • short, long, signed, unsigned: Define variations of integer data types.
2. Control Flow: Keywords that control the flow of program execution.
  • if, else: Used for conditional branching.
  • switch, case, default: Used for switch statements.
  • while, do, for: Used for loops.
3. Functions: Keywords related to functions and their usage.

  • void, return: Used in function declarations and definitions.
  • main: The entry point function of a C program.
4. Storage Classes: Keywords that determine the storage duration and scope of variables.
  • auto, register, static, extern: Control how variables are stored and accessed.
5. Modifiers: Keywords that modify the behaviour of data types.

  • const, volatile: Qualify data types to indicate whether they can be modified or are subject to optimization.
6. Pointers: Keywords related to pointers and memory manipulation.
  • int*, char*, etc.: Used for declaring pointer variables.
  • sizeof: Returns the size of a data type or object in bytes.
  • NULL: Represents a null pointer.
7. Structures and Unions: Keywords for defining complex data structures.
  • struct, union, enum: Define structures, unions, and enumerations.
8. Type Qualifiers: Keywords that modify the properties of data types.
  • const, volatile: Qualify data types to indicate constant or volatile properties.
It's important to note that the set of keywords can vary slightly depending on the C language standard being used (e.g., C89, C99, C11). Additionally, some identifiers that are not reserved might become keywords in future language versions, so avoiding using identifiers that closely resemble keywords is advisable to prevent compatibility issues.

How many keywords are in C language and there types

As of my last knowledge update in September 2021, the C language standard does not have an overwhelmingly large number of keywords compared to some other programming languages. The number of keywords in C depends on the version of the C standard being used. Here's a breakdown of the keywords in the C language according to the C99 standard:


C99 Standard Keywords (32 keywords):
1. auto
2. break
3. case
4. char
5. const
6. continue
7. default
8. do
9. double
10. else
11. enum
12. extern
13. float
14. for
15. goto
16. if
17. inline
18. int
19. long
20. register
21. return
22. short
23. signed
24. sizeof
25. static
26. struct
27. switch
28. typedef
29. union
30. unsigned
31. void
32. while

Please note that this list is based on the C99 standard. Newer versions of the C standard might introduce additional keywords or modify existing ones. For example, the C11 standard introduced the _Alignas and _Static_assert keywords.

Also, some compilers might provide extensions or additional keywords beyond those defined by the standard.

It's recommended to refer to the specific version of the C standard you are working with for the most accurate and up-to-date information regarding keywords.

Explain C language keywords with its meaning

Certainly! Here's an explanation of some important C language keywords along with their meanings and usage:

1. auto: This keyword is used to declare a local variable within a block or function. The variable's storage duration is automatic, meaning it's created when the block is entered and destroyed when the block is exited.

2. if: It is used for conditional branching. The statement following this keyword is executed only if the condition in the parentheses evaluates to true (non-zero).

3. else: Used with if, it specifies an alternative branch of code to be executed when the if condition is false.

4. while: It is used to create a loop that continues executing a block of code as long as the given condition is true.

5. do: Part of the do-while loop construct. It defines a loop where the block of code is executed at least once, and then the condition is checked.

6. for: Used to create a loop that includes initialization, condition checking, and an iteration expression in a single line.

7. switch: Introduces a switch statement, which is used for multi-way branching based on the value of an expression.

8. case: Used within a switch statement to specify different cases that the switch expression can match.

9. break: Used to exit from a loop or switch statement prematurely, terminating the current iteration or exiting the switch block.

10. continue: Causes the loop to skip the remainder of the current iteration and proceed with the next iteration.

11. return: Used in a function to exit the function and optionally provide a return value to the caller.

12. int, char, float, double: Keywords used to declare variables of specific data types (integer, character, floating-point, double-precision floating-point).

13. void: Used in function declarations to indicate that the function does not return a value.

14. const: Specifies that a variable's value cannot be changed after initialization.

15. volatile: Informs the compiler that a variable's value can change at any time without any action being taken by the code the compiler finds nearby.

16. typedef: Used to create aliases (alternative names) for existing data types.

17. struct: Defines a structure, which is a composite data type that groups together variables under a single name.

18. enum: Declares an enumeration, a user-defined data type consisting of a set of named integer constants.

19. sizeof: Returns the size, in bytes, of a data type or an object in memory.

20. static: Changes the storage duration of a variable to last for the entire program's execution.

21. register: Suggests to the compiler that a variable should be stored in a CPU register for faster access.

22. union: Defines a union, a data type that can hold different types of data in the same memory location.

23. unsigned: Specifies that a variable can only hold non-negative values.

24. signed: Specifies that a variable can hold both positive and negative values.

25. goto: Provides an unconditional jump to a labeled statement within the same function.

These are just a selection of C language keywords, and there are more keywords and features available in C. The meanings and usages mentioned above provide a basic understanding of how these keywords are used in C programming. It's important to consult the C language specification or relevant documentation for comprehensive details on each keyword and its usage.

Comments