Unit 1 - II Consts Vars and Data Types
Unit 1 - II Consts Vars and Data Types
int main()
{ printf function called to display the
string “Hello World” to standard
printf(“Hello World”); output device (display).
return 0;
Main function returns value
} 0,with that the program
ends/terminates.
C Character Set 4
C Token: Smallest individual meaningful units in a C program are called Tokens. A Token
consists of 1 or more characters from the C Character Set.
C Tokens
Operator
Keyword Constant
(+,*,-,/)
(e.g. int, void) (e.g. 65,’C’
Identifier String
(e.g. main, sum) “hello”
Keywords 7
int x = 1;
1006
char y = ‘A’; 1005
31(decimal) = 0000000000011111(binary) 1004
8 bits = 1 Byte y 01000001 1003
1024 bytes = 1 KiloByte(KB) 1002
1024 KB = 1 Mega Byte(MB) 1001
x 00000000
1024 MB = 1 Giga Byte(GB) 1000
00000001
1024 GB = 1 Tera Byte (TB)
❑ They do not reserve any bit for representing sign, i.e., they use all
the bits for storing the magnitude of the number.
Integer Type(int) 22
❑ Different integer types are short int, int, long int, unsigned int etc.
Size of each will vary.
❑ Normally short int is smallest, then int and followed by long int,
the largest among three.
❑ short, long, unsigned etc. are called as modifiers for the basic
data type. These are keywords of C language.
❑ Where n is the number of bits available for storing the data part
(magnitude) of the number(Not the sign).
Integer Type (int) 26
tytypestypespiler(GCC) )
❑ short int ==> %hi or %hd
❑ unsigned short int ==> %hu
❑ char ==> %c
❑ int ==> %d
❑ unsigned int ==> %u
❑ long int ==> %ld
❑ unsigned long int ==> %lu
❑ float ==> %f double ==> %lf
❑ long double ==>%Lf
Note: w.r.t GNU C Compiler(GCC)
Declaration of Variables 35