Character Set used in C
Characters are the basic most needed units, which is used to form different words, numbers, operators, constants, expression that means the part of (component of) programming language depending upon the computer on which the program is run. The characters available in C are grouped into following categories.
- Letters
- Digits
- White spaces
- Special characters
- Letters : Letters are alphabet of a language and C is case sensitive so that letter may be upper or lower or both for making words, sentences (statement) etc. For example, A.....Z, a.....z
- Digits : Digits are decimal numbers. For example, 0-9
- White Spaces : Some white space characters like blank space, horizontal tab, carriage return, new line, form feed, etc
- Special Characters : Some special characters are used while making the program in C programming language and these characters are differ from one to another programming language. For example, -, ~, !, #, $, %, ^, &, etc
Comments
The /*......*/ and // both are comment specifier and will not be executed, the compiler simply ignores this statement. These are essential since it enhances the readability and understandability of the program. It is a very good practice to include comments in all the programs to make it understandable the users and to the programmer him/herself what is being done in the program. This /*.....*/ provides multi-line comments and // provides single line comments.
C comments can be written like this:
/* This is a comment */
/* It will be ignored by the compiler */
/* This is also a comment. You don't necessarily
need an ending comment statement at the end of
every line. You only need it at the end of each comment! */
// This is used for single line comments
Identifiers
Identifiers are the any words which are used while making the program. Simply identifier means which identify the existence of used word in different form (meaning). The words and statements which are used that must be formed under the rule of C programming language. Identifiers may be variable, constant, expression, function, array, pointer, structure etc. Identifiers are formed with the combination of characters set.
Rules for naming identifiers are as follows.
- First character must be an alphabet or underscore (_)
- Only letters, digits and underscore are used
- Only first 31 characters are significant
- Cannot use a keyword
- Must not contain a white space
- Better to use meaningful name of an identifier
Keywords
It is also called reserve words. The program is constructed with the help of keywords and identifiers. The keywords are those words which are already defined by the programming language and have fixed meaning and these meanings cannot be changed. These keywords cannot be used as an identifier while making programs. Keywords must be written in lowercase. There are 32 keywords in C programming language. They are as follows.
Term |
Description |
---|---|
auto | Optional location declaration |
break | Used to exit from loop and switch |
case | Choice in a switch statement |
char | Character type declaration |
const | Variable cannot be changed |
continue | Goto bottom of loop |
default | Last case of switch |
do | Body of do while loop |
double | Double precision floating point type declaration |
else | False part of if structure |
enum | User define enumeration type declaration |
extern | Declaration of variable externally |
float | Floating point type declaration |
for | Looping statement |
goto | Jump to a label |
if | Conditional statement |
int | Integer type declaration |
long | Adjective to data type |
register | Variable in register |
return | Return to calling |
short | Adjective to data type |
signed | Adjective to data type |
sizeof | Size of data type |
static | Make local variable static |
struct | Structure type declaration |
switch | Conditional statement for cases |
typedef | User define data type declaration |
union | Union type declaration |
unsigned | Adjective to data type |
void | Less type declaration |
volatile | Variable can be change anytime |
while | Looping statement |
C Tokens
C tokens are the component of C programming language. With the help of these tokens C program is formed. In any valid C statement is not other than C tokens. So, C programs are written using these tokens and the syntax of the programming language. List of tokens are:
- Keywords
- Constants
- Operators
- Identifiers
- Special Symbols
0 Comments