Tokens in C
printf("Hello, World! \n");
The individual tokens are:printf ( "Hello, World! \n" ) ;
Semicolons ;
For example, following are two different statements:
printf("Hello, World! \n");
return 0;
Comments
/* my first program in C */You cannot have comments within comments and they do not occur within a string or character literals.
Identifiers
C does not allow punctuation characters such as @, $, and % within identifiers. C is a case sensitive programming language. Thus, Manpower and manpower are two different identifiers in C. Here are some examples of acceptable identifiers:
mohd zara abc move_name a_123 myname50 _temp j a23b9 retVal
Keywords
| auto | else | long | switch |
| break | enum | register | typedef |
| case | extern | return | union |
| char | float | short | unsigned |
| const | for | signed | void |
| continue | goto | sizeof | volatile |
| default | if | static | while |
| do | int | struct | _Packed |
| double |
Whitespace in C
Whitespace is the term used in C to describe blanks, tabs, newline characters and comments. Whitespace separates one part of a statement from another and enables the compiler to identify where one element in a statement, such as int, ends and the next element begins. Therefore, in the following statement:
int age;There must be at least one whitespace character (usually a space) between int and age for the compiler to be able to distinguish them. On the other hand, in the following statement:
fruit = apples + oranges; // get the total fruitNo whitespace characters are necessary between fruit and =, or between = and apples, although you are free to include some if you wish for readability purpose.
No comments:
Post a Comment