trigraph ??= is for # ??( is for [ ??< is for { ??! is for |
tokens Smallest individual unit is token Keyword e.g. float while Identifier e.g. main,amount Constant e.g. 100 String Special symbol e.g [] {} operator
Keyword & identifier,variable Keyword have Fixed meaning Rules for identifier : - first character alphabet - only letters , digit and underscore - only 31 characters - con not use keyword - no white space
constant
Character & string Character : ‘c’ - printf(“%i”,’c’); => will print 99 - printf(“%c”,’99’); => will print c String : “c” Escape sequence : \n, \t
Data types Primary data type: int, float User defined : tyepdef int unit; unit salary; Derived data tyepe : array,function,structure
Data types
operators
Bitwise operator
showbits( )
One’s Complement Operator
Right Shift Operator
Left Shift Operator
Bitwise AND Operator
Bitwise OR Operator
Operator Precedence
C is middle level language Programming efficiency like high level language and Machine efficiency like low level language
Local and global variable Local variable : declared inside block or function and variable is accessible in block only Global variable : declared in program accessible everywhere in program Life time of variables
Local variables Global variables Declared inside function body Scope local to function Not initialized value variable with same in different function is possible Advisable to use Void main() { int i=4; } Declared outside function body Start to end of program Auto initialized to 0 variable with same in different function is NOT possible Creates difficulty in debugging Int i=1; Void main() { //code }
Storage classes Storage class defines scope and life time of variable Storage class decides location of variable : Memory or CPU registers variable’s storage class tells us: - Where the variable would be stored. - What will be the initial value of the variable, if initial value is not specifically assigned.(i.e. the default initial value). - What is the scope of the variable; i.e. in which functions the value of the variable would be available. - What is the life of the variable; i.e. how long would the variable exist.
Automatic Storage Class
Register Storage Class
Static Storage Class Storage : Memory. Default initial value : Zero. Scope : Local to the block in which the variable is defined Life : Value of the variable persists between different function calls.
External Storage Class