(The following 32 names or words are reserved by the C language)
int
char float double void enum typedef const volatile |
signed
unsigned short long break Continue goto return |
if
else switch case default for while do |
auto
static register extern struct union sizeof |
|
Definition of Keywords
- A keyword is a sequence of characters.
- Keywords have standard, predefined in C.
- The keywords are also called ‘Reserved words’.
- Keywords serve as basic building blocks for program statements.
- Used only for their intended purpose.
Further details about keywords
- Every C word is classified as either a keyword or an identifier.
- Keywords are an essential part of a language definition.
- They implement specific features of the language.
- C compiler readily accepts and recognizes while being used in a program.
- They provide control.
- From libraries which perform special functions.
- Used for giving commands or making statements.
- The basic instructions are built up using a reserved set of words, such as main, for, if, while, default, double, extern, for, and int, etc.,
- Keywords cannot be used as programmer-defined identifiers. . You cannot use double, for example, as the name of a variable. An attempt to do so will result in a compilation error.
- Since uppercase and lowercase characters are not equivalent, it is possible to utilize an uppercase keyword as an identifier.
- 32 keywords available in C.
Restrictions apply for Keywords
- Keywords are the words whose meaning has already been explained to the C compiler and their meanings cannot be changed.
- Keywords can be used only for their intended purpose.
- Keywords cannot be used as user-defined variables.
- All keywords must be written in lowercase.
Data Type Keywords
int Specifies the integer type of value a variable will hold.
char Specifies the character type of value a variable will hold.
float Specifies the single-precision floating -point of value a variable will hold.
double Specifies the double-precision floating -point type of value a variable will hold.
void Specifies the function returns nothing.
char Specifies the character type of value a variable will hold.
float Specifies the single-precision floating -point of value a variable will hold.
double Specifies the double-precision floating -point type of value a variable will hold.
void Specifies the function returns nothing.
Qualifier Keywords
signed Specifies a variable can hold positive and negative integer type of data.
unsigned Specifies a variable can hold only the positive integer type of data.
short Specifies a variable can hold fairly small integer type of data.
long Specifies a variable can hold fairly large integer type of data.
unsigned Specifies a variable can hold only the positive integer type of data.
short Specifies a variable can hold fairly small integer type of data.
long Specifies a variable can hold fairly large integer type of data.
User-defined type keywords
typedef Used to define a new name for an existing data type
Enum Gives an opportunity to invent own data type and define what values the variable of this data type can take
Decision Control Keywords
if It is used to make decisions
else It always comes with if. That is, if-else statement is used to execute an action when the condition is true and another action when the condition is false.
switch It allows us to make a decision from a number of choice. Very useful while writing menu driven programs.
case Within the switch statement, It is labeled by integer valued expression. if a case matches the expression value, execution starts at that case. All case must be different.
break It is used to terminate or to exit from a switch statement.
default Within the switch statement, the case labeled default is executed if none of the other cases are satisfied.
else It always comes with if. That is, if-else statement is used to execute an action when the condition is true and another action when the condition is false.
switch It allows us to make a decision from a number of choice. Very useful while writing menu driven programs.
case Within the switch statement, It is labeled by integer valued expression. if a case matches the expression value, execution starts at that case. All case must be different.
break It is used to terminate or to exit from a switch statement.
default Within the switch statement, the case labeled default is executed if none of the other cases are satisfied.
Loop Control keywords
for Loop is used when the number of passes is known in advance
while Loop is used when the number of passes is not known in advance
do Loop is used to handle menu-driven programs
while Loop is used when the number of passes is not known in advance
do Loop is used to handle menu-driven programs
Jump Control keywords
break Used to force immediate termination of a loop, bypassing the conditional expression and any remaining
code in the body of the loop.
continue Used to take the control to the beginning of the loop bypassing the statements inside the loop.
goto Used to take the control to required place in the program. It is used to transfer the control in a loop or a
function form one place to any other portion in that program.
return It is used to return from a function.
code in the body of the loop.
continue Used to take the control to the beginning of the loop bypassing the statements inside the loop.
goto Used to take the control to required place in the program. It is used to transfer the control in a loop or a
function form one place to any other portion in that program.
return It is used to return from a function.
Type Qualifiers Keywords
volatile
const
- This modifier tells the compiler that a variable's value may be changed in ways not explicitly by the program.
const
- Variables of type const may not be changed by your program.
- A const variable can be given an initial value.
- The compiler is free to place variables of this type into ROM.
- This qualifier can be used to prevent the object pointed to by an argument to a function from being modified by that function.
Operator keyword
sizeof
- It is an operator, always preceeds its operand.
- It is not a library function.
- It is a keyword.
- It returns the size of the operand in bytes.
- It can be used for dynamic memory allocation.
- Information obtained from this operator can be very useful when transferring a program to a different computer.
Storage Class Specifiers
Storage Classes
auto register static extern |
Storage
Memory CPU registers Memory Memory |
Default initial value
An unpredictable value Garbage value Zero Zero |
Scope
Local Local Local Global |
Life
Till the control remains within the block Till the control remains within the block Value of the variable persists between different function calls Till the program’s execution doesn’t come to an end |
Review Questions in
Storage Class Specifier
Review Questions in Jump Keywords
|
Review Questions in
User-defined type Keywords
Review Questions in Operator Keywords
|
Review Questions in
Data Type Keywords
Review Questions in Qualifiers Keywords
|
Review Questions in
Decision Control Keywords
Review Questions in Loop Control Keywords
|
Part - A
- Define Keyword. (Or) Define Reserve word.
- What is a keyword? (Or) What is a Reserve word?
- List any four key words of C language.
- What are keywords? Give examples.
- What are the restrictions apply for keywords?
- Write short notes on: keywords (Reserved words)
- State the meaning of the following keywords: auto, if
- Explain about storage class specifiers.
- Write short notes on: Data Type Keywords
- Write short notes on: Qualifiers Keywords
- Write short notes on: User-defined Keywords.
- Write short notes on: Decision Control Keywords
- Write short notes on: Loop Control Keywords
- Write short notes on: Storage Class Specifiers Keywords
- Write short notes on: Jump Keywords
- Write short notes on: Type Qualifiers Keywords.