Keywords in C Language

In C language, there are certain words that have special meanings, and you can't use them for your own made-up purposes. They are reserved for specific jobs in the C world.

1. auto:

auto is used to declare automatic variables. It suggests the compiler to infer the data type based on the variable's initialization.

2. break:

break is used to exit from a loop or switch statement. It breaks out of the current block of code.

3. case:

case is used in a switch statement. It represents one of the possible values that the switch expression can have.

4. char:

char is a keyword used to declare a variable that can hold a character (like 'a' or '@').

5. const:

const is used to declare constants. It means the value assigned to the variable cannot be changed during the program.

6. continue:

continue is used to skip the rest of the loop's code and move to the next iteration.

7. default:

default is used in a switch statement. It represents the default case when none of the other cases match the switch expression.

8. do:

do is used to create a do-while loop. It repeats a block of code while a specified condition is true.

9. double:

double is a keyword used to declare a variable that can hold double-precision floating-point numbers.

10. else:

else is used in an if-else statement. It represents the block of code to be executed if the condition in the if statement is false.

11. enum:

enum is used to define an enumeration, which is a set of named integer constants.

12. extern:

extern is used to declare a variable or function that is defined in another file or will be defined later in the program.

13. float:

float is a keyword used to declare a variable that can hold floating-point numbers.

14. for:

for is used to create a for loop. It repeats a block of code a specified number of times.

15. goto:

goto is used to transfer control to a labeled statement within the same function.

16. if:

if is used to create an if statement. It executes a block of code if a specified condition is true.

17. int:

int is a keyword used to declare a variable that can hold integer numbers.

18. long:

long is used to declare a variable that can hold a larger range of integer values.

19. register:

register is used to suggest to the compiler that a variable should be stored in a register for faster access.

20. return:

return is used to exit a function and optionally return a value.

21. short:

short is used to declare a variable that can hold a smaller range of integer values.

22. signed:

signed is used to declare a variable with a sign (positive or negative).

23. sizeof:

sizeof is used to determine the size, in bytes, of a variable or data type.

24. static:

static is used to declare a variable or function that retains its value or scope throughout the program's execution.

25. struct:

struct is used to define a structure, which is a user-defined data type that can hold variables of different data types.

26. switch:

switch is used to create a switch statement. It allows a variable to be tested for equality against a list of values.

27. typedef:

typedef is used to create an alias or a new name for an existing data type.

28. union:

union is used to define a union, which is a user-defined data type that can hold variables of different data types but only one at a time.

29. unsigned:

unsigned is used to declare a variable without a sign (only positive values).

30. void:

void is used to declare functions that do not return a value or to indicate that a function has no parameters.

31. volatile:

volatile is used to indicate that a variable can be changed by something outside of the program, like hardware.

32. while:

while is used to create a while loop. It repeats a block of code while a specified condition is true.

These keywords have specific meanings in C, and they play crucial roles in defining the structure and behavior of a C program.

Post a Comment

0 Comments