| These elements include the C character set, identifiers, and keywords, data types, constants, variables and arrays, declaration, expressions and statements. |
| C character set and keywords |
| |
| The C character set |
| |
| C uses the uppercase letter A to Z, the lowercase letters a to z, the digits 0 to 9, and certain special characters as building blocks to form basic program elements ( e.g., constants, variables, operators, expressions, etc.). |
| |
| Some of the special characters are listed below: |
| |
|
|
| |
| Most versions of the language also allow certain other characters, such as @ and $, to be included within strings and comments. |
| |
| C uses certain combinations of these characters, such as \b,\n and \t, to represent special conditions such as backspace, new line, and horizontal tab, respectively |
| These character combinations are known as escape sequences. |
| |
|
|
| C character set and keywords |
| |
| Identifiers |
| |
| Identifiers are names that are given to various program elements, such as variable,functions and arrays. |
| |
| Identifiers consist of letters and digits, in any order, except that the first character must be a letter.; |
| |
| Both upper- and lowercase letters are permitted, though common usage favors the use of lowercase letters for most types of identifiers. Upper- and lowercase letters are not interchangeable. |
| |
| The underscore (_) character can also be included, and is considered to be a letter. An underscore is often used in the middle of an identifier. |
| |
| An identifier may also begin with an underscore, though this is rarely done in practice. |
| |
| The following names are valid identifiers: |
| |
| x | y12 | sum_1 | tax_rate | area | _temperature |
|
| |
| |
|
|
| |
| C character set and keywords |
| |
| Key words |
| |
| There are certain reserved words, called keywords, which have standard, predefined meanings in C. |
| |
| These keywords can be used only for their intended purpose; they cannot be used as programmer-defined identifiers. |
| |
| Some standard keywords are: |
| |
| auto | extern | sizeof | break | floatn | static | case | for | char |
|
| |
| switch | register | return | long | int | else | while | short | void |
|
| |
| Some C compilers may recognize other keywords. |
| |
| Note that the keywords are all lowercase. Since uppercase and lowercase characters are not equivalent, it is possible to utilize an uppercase keyword as an identifier. |
| |
| Normally, however, this is not done, as it is considered a poor programming practice. |
| |
| |
|
|
| |
| |
|
|
|
No comments:
Post a Comment