List of Keywords in C

In C programming, keywords are reserved words that have specific meanings and cannot be used as identifiers such as variable names or function names. Understanding each keyword’s purpose is essential for mastering C programming.

KeywordDescription
1. autoDeclares automatic local variables (default storage class).
2. breakExits from a loop or a switch statement.
3. caseDefines a case in a switch statement.
4. charDeclares a variable of type character.
5. constDeclares a constant variable whose value cannot be changed.
6. continueSkips the current iteration of a loop and moves to the next iteration.
7. defaultSpecifies the default case in a switch statement.
8. doUsed to create a do-while loop.
9. doubleDeclares a variable of type double (double-precision floating-point).
10. elseSpecifies the alternative block of code in an if statement.
11. enumDeclares an enumeration (a set of named integer constants).
12. externDeclares a variable or function that is defined in another file or scope.
13. floatDeclares a variable of type float (single-precision floating-point).
14. forCreates a loop that repeats a block of code a specified number of times.
15. gotoPerforms an unconditional jump to a labeled statement.
16. ifSpecifies a conditional statement.
17. intDeclares a variable of type integer.
18. longDeclares a variable of type long integer.
19. registerSuggests storing the variable in a CPU register for faster access.
20. returnExits from a function and optionally returns a value.
21. shortDeclares a variable of type short integer.
22. signedDeclares a signed data type, which can hold negative values.
23. sizeofReturns the size of a data type or object in bytes.
24. staticDeclares a static variable that retains its value between function calls.
25. structDeclares a structure, a collection of variables of different types.
26. switchCreates a switch statement for multi-way branching.
27. typedefCreates an alias for a data type.
28. unionDeclares a union, which allows different data types to share the same memory location.
29. unsignedDeclares an unsigned data type, which cannot hold negative values.
30. voidSpecifies that a function returns no value or declares a pointer to no type.
31. volatilePrevents the compiler from optimizing the variable.
32. whileCreates a loop that repeats a block of code as long as a condition is true.

1. auto

  • Purpose: Declares automatic variables. This is the default storage class for local variables.
  • Usage: auto is rarely used since all local variables are automatically considered auto.

2. break

  • Purpose: Terminates the execution of a loop (for, while, or do-while) or a switch statement.

3. case

  • Purpose: Defines individual cases within a switch statement. Each case represents a different possible value of the expression being evaluated.

4. char

  • Purpose: Declares a variable of type character, which stores a single character (1 byte) value.

5. const

  • Purpose: Declares a constant variable whose value cannot be changed once it is initialized.

6. continue

  • Purpose: Skips the rest of the current loop iteration and moves to the next iteration.

7. default

  • Purpose: Specifies the default case in a switch statement when none of the case values match.

8. do

  • Purpose: Used in do-while loops. Executes the block of code at least once before checking the condition.

9. double

  • Purpose: Declares a variable of type double, which holds a double-precision floating-point number.

10. else

  • Purpose: Specifies the alternative block of code in an if-else statement, executed when the if condition is false.

11. enum

  • Purpose: Defines a set of named integer constants.

12. extern

  • Purpose: Declares a variable or function that is defined in another file or scope. It is often used in multi-file programs.

13. float

  • Purpose: Declares a variable of type float, which holds a single-precision floating-point number.

14. for

  • Purpose: Creates a loop that repeats a block of code a fixed number of times.

15. goto

  • Purpose: Performs an unconditional jump to a labeled statement. It is generally discouraged because it can make code difficult to follow.

16. if

  • Purpose: Specifies a conditional statement that executes a block of code if the condition is true.

17. int

  • Purpose: Declares a variable of type integer.

18. long

  • Purpose: Declares a variable of type long integer, which can store larger integer values than a regular int.

19. register

  • Purpose: Suggests that the variable should be stored in a CPU register for faster access. It is a hint to the compiler, and the compiler may ignore it.

20. return

  • Purpose: Exits from a function and optionally returns a value.

21. short

  • Purpose: Declares a variable of type short integer, which takes up less memory than a regular int.

22. signed

  • Purpose: Declares a signed data type, meaning it can store both negative and positive values. It is often used with char or int.

23. sizeof

  • Purpose: Returns the size of a data type or object in bytes.

24. static

  • Purpose: Declares a variable that retains its value between function calls, or limits the scope of a variable to a file (in case of global variables).

25. struct

  • Purpose: Declares a structure, which is a collection of variables of different types.

26. switch

  • Purpose: Creates a switch statement for multi-way branching based on the value of an expression.

27. typedef

  • Purpose: Creates an alias for a data type.

28. union

  • Purpose: Declares a union, which is a data structure where all members share the same memory location, meaning only one member can be used at a time.

29. unsigned

  • Purpose: Declares an unsigned data type, which cannot store negative values.

30. void

  • Purpose: Declares a function that does not return any value or specifies a pointer to no type.

31. volatile

  • Purpose: Prevents the compiler from optimizing the variable. This is useful when a variable can be changed unexpectedly, such as in hardware or interrupts.

32. while

  • Purpose: Creates a while loop that repeats a block of code as long as the condition is true.

Understanding the purpose of each keyword in C is crucial for writing efficient, correct, and maintainable code. Keywords serve as the backbone of the C language,

enabling everything from basic variable declarations to complex control structures.

At SamagraCS Educational Technology, we encourage you to practice using these keywords in real programs to gain a deeper understanding of how they work. If you have any questions or need further assistance, feel free to reach out to Pawan & Pooja, or the team. Keep learning and happy coding!

error: Content is protected !!
Open chat
1
Hi,how Can We Help You ?
Exit mobile version