Keywords Available in Both C and C++
C and C++ share a set of keywords since C++ was initially designed as an extension of the C language. Here are the keywords available in both C and C++:
- auto: Specifies automatic storage duration for a variable.
- break: Terminates the execution of a loop or switch statement.
- case: Labels a statement within a switch statement.
- char: Defines a character data type.
- const: Specifies that a variable's value cannot be modified.
- continue: Skips the current iteration of a loop and proceeds to the next iteration.
- default: Specifies the default case in a switch statement.
- do: Initiates a do-while loop.
- double: Defines a double-precision floating-point data type.
- else: Specifies the alternative condition in an if statement.
- enum: Declares an enumeration type.
- extern: Specifies external linkage for a variable or function.
- float: Defines a single-precision floating-point data type.
- for: Initiates a for loop.
- goto: Transfers control to a labeled statement.
- if: Initiates an if statement.
- int: Defines an integer data type.
- long: Defines a long integer data type.
- register: Suggests to the compiler to store a variable in a register.
- return: Returns a value from a function.
- short: Defines a short integer data type.
- signed: Specifies signed integer types.
- sizeof: Returns the size of a data type or variable.
- static: Specifies static storage duration for a variable or function.
- struct: Defines a structure type.
- switch: Initiates a switch statement.
- typedef: Creates an alias for a data type.
- union: Defines a union type.
- unsigned: Specifies unsigned integer types.
- void: Specifies an empty or incomplete data type.
- volatile: Indicates that a variable may be modified by external factors.
- while: Initiates a while loop.
These keywords are part of the core syntax and semantics shared by both C and C++, allowing developers to write code that is compatible with both languages. However, while these keywords are common, there are differences in the way some features are implemented or used between C and C++.
Thank you,