Programmer Coding

What is keywords in C?

Keywords in C language are reserved words defined before definitions and functions in C programming language. Because these elements are reserved by the language for special purposes, they cannot be used as symbols such as variable names, function names, or letters.

 

Here are some examples of C language keywords

 

 

  • auto: This keyword automatically declares a variable; This means that the variable is local to the block and is destroyed at the end of the block.

Syntax

auto int num = 10;

  • break: It is used to break the loop or change the expression it is in.

Syntax

for (int i = 0; i < 10; i++) {

if (i == 5) {

break;

}

printf(“%d “, i);

}

  • case: This keyword is used to modify sentences to indicate different situations.

Syntax

switch (num) {

case 1:

printf(“One”);

break;

case 2:

printf(“Two”);

break;

default:

printf(“Other”);

}

  • char: It is a fundamental data type that represents characters.

Syntax

char ch = ‘A’;

  • const: Declares a constant, that is, a variable whose value cannot be changed.

Syntax

const int MAX_SIZE = 100;

  • continue: It is used to skip the current iteration of the loop and continue to the next iteration.

Syntax

for (int i = 0; i < 10; i++) {

if (i == 5) {

continue;

}

printf(“%d “, i);

}

  • default: Shows status on transition notification.

Syntax

switch (expression) {

case constant_expression1:

// Statements

break;

case constant_expression2:

// Statements

break;

default:

// Statements

}

  • do: Start do-while loop.

Syntax

do {

// Statements

} while (condition);

  • double: interprets double precision floating point data.

Syntax

double variable_name;

  • else: Shows other events in the description.

Syntax

if (condition) {

// Statements

} else {

// Statements

}

  • enum: Define the enumeration type.

Syntax

enum enum_name {

constant1,

constant2,

// More constants

};

  • extern: Declare variables and functions defined in other files.

Syntax

extern data_type variable_name;

  • float: defines single precision floating point data.

Syntax

float variable_name;

  • for: Start the cycle.

Syntax

for (initialization; condition; iteration) {

// Statements

}

  • goto: Transfer control to the specified message.

Syntax

goto label_name;

  • if: It is the starting statement.

Syntax

if (condition) {

// Statements

}

  • int: Interpret the data number.

Syntax

int variable_name;

  • long: defines the file length integer.

Syntax

long variable_name;

  • Register: Tells the compiler that changes should be stored in registers.

Syntax

register data_type variable_name;

  • return: Exits the function and returns the value.

Syntax

return expression;

  • short: Define short integer data type.

Syntax

short variable_name;

  • signed: Defines a type of signature file that can store positive and negative values.

Syntax

signed data_type variable_name;

  • sizeof: Returns the size of a data type or variable.

Syntax

sizeof(data_type); or sizeof(variable);

  • static: Declare variables and function as static.

Syntax

static data_type variable_name;

or

static return_type function_name(parameters);

  • struct: Definition of structure.

Syntax

struct struct_name {

data_type member1;

data_type member2;

// More members

};

  • switch: Start a spreadsheet to select one of many blocks of code to process.

Syntex

switch (expression) {

case constant1:

// Statements

break;

case constant2:

// Statements

break;

default:

// Statements

}

  • typedef: Identify the new file using the namespace

Syntex

typedef data_type new_data_type;

  • Union: Definition of the union type.

Syntex

union union_name {

data_type member1;

data_type member2;

// More members

};

  • unsigned: Identifies the unsigned file type.

Syntex

unsigned data_type variable_name;

  • void: Custom function does not return a value.

Syntex

void function_name(void) {

// Statements

}

  • Volatile: Indicates that the variable can be changed by external sources.

Syntex

volatile data_type variable_name;

  • while: Initiates a while loop.

Syntex

while (condition) {

// Statements

}

1 thought on “What is keywords in C?”

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top