Character set
Character set are the set of alphabets, letters and some special characters that are valid in C language
Alphabets :
Uppercase : A, B, C, ...............................X, Y, Z.
Lowercase : a, b, c, ..................................x, y, z.
Digits :
0 1 2 3 4 5 6 7 8 9
Special Characters :
, < > . _ ( ) ; $ : % [ ] # ?
' & { } " ^ ! * / | - \ ~ +
Keywords :
Keywords are the reserved words used in programming. Each keywords has fixed meanings that cannot be changed by user. For example :
int money;
Here, int is a keyword that indicates, 'money' is of type integer.
As C programming is case sensitive all keywords must be written in lowercase. Here is the list of all keywords predefined by ASCII C.
auto double int struct
break else long switch
case enum register typedef
char extern return union
continue for signed void
do if static while
default goto sizeof volatile
const float short unsigned
Identifiers :
In C programming identifiers are the name given to C entities such as variables, functions, structures, etc. Identifiers are created to give unique name to C entities to identify it during the execution of program.
For example
int money;
int mango_tree;
Here, money is a identifier which denotes a variable of type integer. Similarly, mango_tree is another identifier which denotes another variable of type integer.
Variables
int num;
Here, num is a variable of integer type.
Rules for writing variable name in C
- Variable name can be composed of letters (both uppercase and lowercase letters), digits and underscore '_' only.
- The first letter of a variable should be either a letter or an underscore. But, it is discouraged to start variable name with an underscore though it is legal. It is because, variable name that starts with underscore can conflict with system names and compiler may complain.
- There is no rule for the length of length of a variable. However, the first 31 characters of a variable are discriminated by the compiler. So, the first 31 letters of two variables in a program should be different.
In C programming, you have to declare variable before using it in the program.
Constants
Integer constants
Decimal digits: 0 1 2 3 4 5 6 7 8 9
Octal digits: 0 1 2 3 4 5 6 7
Hexadecimal digits: 0 1 2 3 4 5 6 7 8 9 A B C D E F.
For example:
Decimal constants: 0, -9, 22 etc
Octal constants: 021, 077, 033 etc
Hexadecimal constants: 0x7f, 0x2a, 0x521 etc
Notes:
- You can use small caps a, b, c, d, e, f instead of uppercase letters while writing a hexadecimal constant.
- Every octal constant starts with 0 and hexadecimal constant starts with 0x in C programming.
Floating-point constants
-2.0
0.0000234
-0.22E-5
Note:Here, E-5 represents 10-5. Thus, -0.22E-5 = -0.0000022.
Character constants
Escape Sequences
Escape Sequences
Escape Sequences Character
\b Backspace
\f Form feed
\n Newline
\r Return
\t Horizontal tab
\v Vertical tab
\\ Backslash
\' Single quotation mark
\" Double quotation mark
\? Question mark
\0 Null character
String constants
"good" //string constant
"" //null string constant
" " //string constant of six white space
"x" //string constant having single character.
"Earth is round\n" //prints string with newline
Enumeration constants
enum color {yellow, green, black, white};
Here, the variable name is color and yellow, green, black and white are the enumeration constants having value 0, 1, 2 and 3 respectively by default.
0 comments:
Post a Comment