C LANGUAGE
Description of all Keywords in C
-
auto
auto is used to define a variable of storage class automatic.
This statement suggests that var1 is a variable of storage class auto and data type int. Variables declared within function bodies are automatic by default. They are recreated each time a function is executed. Since, automatic variables are local to a function, automatic variables are also called local variables.
-
break and continue
The break statement is used to jump out of the innermost enclosing loop (while, do, for or switch statements) explicitly and pass control to next statement immediately following the loop. In other hand, continue statement is used to skip certain statements inside the loop
The output of the given code is:1 2 4 5 6It is because, when i=3, continue statement comes to effect and skips 3 and when i=7, break statements come to effect and terminates the loop.
-
switch, case and default
The switch statement tests the value of a expression and test with the different "case" values. We can use "default" value, if it doesn't matches any of "case" values. For example:
-
char
The char keyword is used for indicating the variable is of the type character. For example:
Here, variable0 is a variable of type character.
-
const
const makes the value of a pointer or a variable unmodifiable.
In this example, a is the constant and its value is 5. This value cannot be changed in program.
-
do and while
while and do are used for looping in C. For example:
Output of the program
If programmer finds easy to write statements to be executed before writing test condition, do...while loop is used.
-
double and float
double and float are used for indicating floating type variables. Keywords float and double represents single precision and double precision floating point data respectively. For example:
Here, variable1 is single precision floating type variable whereas, variable2 is a double precision floating type variable.
-
if and else
if and else are used in decision making in C
If value of i is other than 1, output will be :
-
enum
enum is used to define enumerated type data type. Enumerated data type creates a set of constant of type int. For example:
Here, a enumerated variable enum_var is created having tags: var1, var2 and var3.
-
extern
Keyword extern is used for indicating the variable is external and is declared outside every function and can be accessed by any function. For example:
Output of the given code is:
-
for
Keyword for is used for looping in C. For example
Output of the code given:
-
goto
Keyword goto is used for unconditional jump to a labeled statement inside that function. For example:
-
int
int is used for indicating the variable is of type integer.
Here, var0 is a variable of type integer.
-
short, long, signed and unsigned
short, long, signed and unsigned are type modifiers that alters the meaning of base data type to yield new type.
Here, the int type variable is modified to short int, long int, signed int and unsigned int respectively.
-
return
Keyword return terminates the execution of current function and returns the value to the calling function.
This function func() returns 5 to to the calling function.
-
sizeof
sizeof is used to find the number of bytes of an object.
Output of the given code
Here, sizeof(...) is used to find the number of bytes of type char.
-
register
Variable of storage class register are much faster than normal variables.
Here, var1 is the variable of storage class register
-
static
static is used for indicating the variable is of storage class static. The value of the static variables persists until the end of the program. For example:
Here, var is a variable of storage class static.
-
struct
struct is used in creating a structure which provide means to group different types of variable under one name for easier handling.
Here, struct keyword is used in creating a structure of tag name student and variables of type "struct student".
-
typedef
Keyword typedef is used to explicitly associate a type with an identifier.
Here, the use of typedef is to create a type kg and this kg type is used in declaring variables bear and tiger.
-
union
Union is used in creating a union which provide means to group different types of variable under one name for easier handling.
Here, union keyword is used in creating a union of tag name student and variables of type "union student".
-
void
void is used to indicate that a function takes no arguments or returns no value
Here, function no_return( ) can take value but, can't return value because, the return type is void.
-
volatile
volatile is used to create a volatile object. A volatile object can be modified in unspecified way by the hardware.
Here, number is a volatile object. Since, number is constant variable, program can't change it but, hardware can change it because, it is a volatile object.
