Keyword in Some Details
Some Information About the Keywords in C
- Keywords for Storage Type
- auto - This is default class of variables declare in the scope. This is very rarely used while writing program in C language. Auto variables are only accessed within a block or scope they have been declared. You can access these variables by using concept of pointers. They are assigned a garbage value by default whenever they are declared.
- extern – External Storage class used for access a variable from 1 file to another where we creating a large program in C language.
- static – Static class is used to declare a static variables. Static variables are popularly used keyword while writing programs. A variable that are declared as static, their values not change even the variable is out of the scope.
- register – Register class is same as Auto class but the only difference is that the variables are declared as register is stored in a register of microprocessor.
- Keywords for User Defined Data Types
- struct – This keyword is used to create a structure in C. Structure is a user defined data types that can be used to group items in a single type.
- union – Union is same as Structure but the difference is All members in the union share the memory. Which means the if you change the one member value change will reflect in all the members. So use it with carefully.
- enum – Enumeration (enum) is the user defined data types it used to assign names of integer constant, the names make a program easy to read and maintain
- Keywords for Data Types
- int – is the data type of Integer value.
- char – It stores the single character.
- float – it is used to stores the Decimal Value with single precision
- double - it is also used to stores the Decimal Value but with double precision
- long – it is a same as int. but it can store more than int. means the capacity of storing values is more the int.
- short – it is a same as int but it can store less than int. means the capacity of storing values is less than the int.
- signed – if variable declare as signed (data-type) then value can be negative or positive. it is default by c program.
- unsigned – if variable declare as unsigned (data-type) then the value is only positive.
- Keywords for Type Qualifiers
- const – this defines the variable cannot change during program. That means the variable value is constant. It is declares as const int MYVAR = 10;
- volatile – This defines the variable value can be change anytime from anywhere from in or outside of the program.
- Keywords for Conditional (Decision Making)
- if – this is widely used keywords in decision making operations.
- else – this is write after if block. If condition not true then else block will execute.
- switch – The Switch statement holds the value which will be compare.
- case – the case keyword is inside the switch block. It compares the value hold by the switch. If any matches will happens it will execute the case statement.
- default – it is also used inside the switch block. If in the switch…case statement no case was true then it will execute the default statement written with the default keyword.
- Keywords for Loops
- for – this is widely used loops in any programming. When we know how many times we need to print any value.
- while – this loop can be used when we don’t have an idea about how many times we need to print or how many time it will repeat then we will use this loop.
- do – this is used for do…while loop. this is same as while loop but the only difference is that it will execute first and then checks the condition or we need to print any values or not. That means if the condition in the given in while statement is false or true the do block will execute at least ones.
- continue – this statement or keyword tell the compiler the work for this repeat is complete please continue to next possible repeat.
- break – this keyword tells the compiler the work of this loop is now over please move out from the block. Or in the simple work get out from the block.
- Other Keywords
- typedef – this keyword is used to assign name of existing data-type to any name.for ex, typedef int* MyPtr; so I have declared variables as MyPtr a,b.
- sizeof – this is used to obtain the size of variable. It returns the size of types in byte.
- goto – this is an uncondition jump. And it is used to jump from goto statement to the label provides with goto statement. For ex, goto MyLable;
- return – this keyword indicates the compiler now you have to go back from the function with or without the value. As the return value will provide at the declaration of the function. Like
int myfun(){ // some lines of code. return myvalue; }
Here int declare as return type of the function. - void – this is the return type and used with the function that indicates to compiler there are no value return from the function.
Comments
Post a Comment