
Keywords in c
Keywords are predefined, reserved words that have special meanings and purposes within the language. These keywords are part of the syntax and cannot be used as identifiers (such as variable names, function names, or labels) because they are already reserved by the C language to perform specific tasks or operations.
Reserved Usage : Keywords are reserved by the C language and have specific predefined meanings. They are used to define the structure and behavior of programs.
Syntax Components : Keywords are integral to the syntax of the language. They dictate how statements, expressions, and control structures are constructed and interpreted by the compiler.
Standardization : Keywords are standardized across all conforming implementations of C. This ensures consistency in language features and behavior across different compilers and platforms.
Keywords | Description |
auto | Specifies automatic storage class. |
break | Exits from a loop or switch statement. |
case | Specifies a branch in a switch statement. |
char | Declares a character type. |
const | Declares a constant. |
continue | Skips the current iteration of a loop and proceeds to the next iteration. |
default | Specifies the default case in a switch statement. |
do | Starts a do-while loop. |
double | Declares a double-precision floating-point type. |
else | Specifies an alternative branch in an if statement. |
enum | Declares an enumeration type. |
extern | Declares a variable or function as existing externally. |
float | Declares a floating-point type. |
for | Starts a for loop. |
goto | Transfers control to a labeled statement. |
if | Specifies a conditional statement. |
int | Declares an integer type. |
long | Declares a long integer type. |
register | Specifies a register storage class. |
return | Exits from a function and optionally returns a value. |
short | Declares a short integer type. |
signed | Declares a signed integer type. |
sizeof | Determines the size of a data type or object. |
static | Declares a static storage class. |
struct | Declares a structure type. |
switch | Starts a switch statement. |
typedef | Defines a new data type. |
union | Declares a union type. |
unsigned | Declares an unsigned integer type. |
void | Specifies an empty or no return type. |
volatile | Indicates that a variable can be modified unexpectedly. |
while | Starts a while loop |
Output :
3.140000
Output :
5
Output :
1 3 5 7 9
Syntax Definition : Keywords define the grammar and structure of C programs. They specify how statements are formed, how control flows, and how data is manipulated.
Compiler Recognition : Keywords are recognized by the compiler and have specific meanings attached to them. Using keywords incorrectly (such as using them as variable names) will result in compilation errors.
Standardization : The use of standardized keywords ensures portability and compatibility of C programs across different systems and compilers.
Since keywords have reserved meanings, it is crucial not to use them as identifiers in your C programs. Using a keyword as an identifier will lead to syntax errors during compilation because the compiler expects these words to be used in specific contexts defined by the C language syntax.
Understanding keywords in C involves recognizing their reserved status, their integral role in defining language syntax, and the importance of using them correctly to ensure proper program execution. By adhering to these principles, developers can leverage the full power and functionality of the C language effectively and efficiently.