ADVERTISEMENT
ADVERTISEMENT

What are Keywords in C Programming?

In the C programming language, a keyword is a word that is reserved by the language and has a special meaning. Keywords are also sometimes referred to as reserved identifiers.

Keywords are used to identify and classify elements of the language, such as statements, data types, and other elements. They are a fundamental part of the language syntax and cannot be used as identifiers (e.g., names for variables, functions, etc.) unless they are being used in their intended context.

Here is a list of some of the keywords in C with meaning:

  • auto: This keyword is used to declare variables that have automatic storage duration. Automatic storage duration means that the variables are allocated on the stack and are automatically deallocated when the block in which they are defined is exited.

  • break: This keyword is used to terminate a loop or a switch statement. When a break statement is encountered inside a loop or a switch statement, control is transferred out of the loop or switch statement to the next statement following the loop or switch.

  • char: This keyword is used to declare variables of type char, which are used to represent single characters.

  • const: This keyword is used to declare variables that are constant and cannot be modified.

  • continue: This keyword is used to skip the rest of the current iteration of a loop and start the next iteration.

  • default: This keyword is used in a switch statement to specify a branch of code to be executed if none of the case values match the value of the switch expression.

  • do: This keyword is used to start a do-while loop, which is a type of loop that is executed at least once and then continues to execute as long as the loop condition is true.

  • else: This keyword is used in an if-else statement to specify the code to be executed if the condition in the if statement is false.

  • enum: This keyword is used to define an enumeration, which is a user-defined data type that consists of a set of named integer constants.

  • extern: This keyword is used to declare variables or functions that are defined in another source file.

  • float: This keyword is used to declare variables of type float, which are used to represent single-precision floating-point numbers.

  • for: This keyword is used to start a for loop, which is a type of loop that allows you to specify an initialization, a condition, and an iteration expression.

  • goto: This keyword is used to transfer control to a labeled statement.

  • if: This keyword is used to start an if statement, which is a type of conditional statement that executes a block of code if a condition is true.

  • int: This keyword is used to declare variables of type int, which are used to represent integers.

  • long: This keyword is used to declare variables of type long, which are used to represent long integers.

  • register: This keyword is used to declare variables that are stored in a register instead of in memory.

  • return: This keyword is used to return a value from a function.

  • short: This keyword is used to declare variables of type short, which are used to represent short integers.

  • signed: This keyword is used to declare variables of a signed integer type.


ADVERTISEMENT

ADVERTISEMENT