Sunday, June 30, 2013

Keywords in C

A keyword is a predefined word or a reserved word for a purpose. In C language there are totally 32 keywords. All the key words and their description is mentioned in the following tabular format. Please check the following table for a better understanding of each of the keyword.




Keyword
Description
auto
Default Storage Class
break
Command that exits the current flow unconditionally in for, while, switch, do…while
case
Command used within switch statement
char
C data type used to carry characters.
const
Data modifier that prevents a variable from being changed.
continue
Command that resets loops to next iteration.
default
Command used within the switch statement to catch any instances which doesn’t go under any case.
do
Looping command used in do…while loop
double
Data type that holds double precision floating-point variables.
else
Alternative path if failed in if condition.
enum
Data type that allows variables to be declared that accepts only certain values.
extern
Data modifier indicating that a variable will be declared in another area of the program.
float
Floating-point data type
for
Looping command
goto
Jump to predefined label.
if
Condition statement
int
Integer data type
long
Larger Inetegr values data type
register
Storage modifier to make storage in registers.
return
For returning a value to calling function
short
Used to store small integer values.
signed
To signify that variable can have both positive and negative values.
sizeof
Returns the size in bytes.
static
To signify that compiler should retain its value.
struct
To define structures
switch
To choose between cases using a single variable
typedef
To create new names for existing variable and function types.
union
To create unions
unsigned
To signify that it takes only positive values.
void
To state that it is nothing or returning nothing.
volatile
Signifies that a variable can be changed.
while
Looping Statement

All these keywords are reserved words in C. These words can't be used for other purposes in C. These keywords can't be used as variable names in C.

Along with these keywords, there is another word which doesn't come under the keywords but can't be used as a variable in C i.e., asm.

ASM in C:

asm in a word which helps us to write inline Assembly code. We can write the assembly code in between a C program by just writing inside of the asm.

For example, 

asm("movl %ebx, %eax");
This statement moves the contents of the register ebx into the register eax.

Also we can write the above statement as 
_asm_("assembly code");

Thus we can embed assembly code into our C program.