Character set of C Language:
C compiler allows to use many no. of characters :
Lower case letters : a b c … z
Upper case letters : A B C….Z
Digits : 0 1 2 3…9
Other characters : + - * ( ) & % $ # { } [ ]’ “ : ; etc.
White space characters : blank, new line, tab space etc.
Conversion Characters( format specifiers):
Conversion characters or format specifiers are used to provide the
format
for the value to be print.. it has a prefix ‘ % ‘ and followed by
a specifier.
%d : prints integer
%f : prints float and double
%c : prints character
%s : prints string
%o : prints octal value
%u : prints unsigned integer
%x : prints hexa decimal value
Escape Sequences:
Escape sequences are used in input and output functions such as
printf
and scanf. Which has ‘\’ and a following character.
\n à new line
\t à horizental tab
\v à vertical tab
\b à back space
\? àquestion mark
\” à double quote
Data type Memory Format specifier
int 2 bytes %d, %i
char 1 bytes %c
float 4 bytes %f
double 8 bytes %f
string Size of char array %s
Unsigned int 2 bytes %u
Long unsingned 8 bytes %lu
long 4 bytes %ld
Differences between variables and identifiers :
Variables are tokens defined by user and used in programming. It
must
start with a letter or underscore(_), it can’t include spaces, it
can contain
digits.
Valid invalid
int x int 3x
float pi float pi+var
int a_b inta.b
the names of variables, functions, labels and other user defined
functions
are called as identifiers.
All identifiers are not variables All variables are identifiers Identifier may not have any
memory unless it is a variable All variables have memory Mentioning the type of an
identifier is not needed unless it is a variable. Type of the variable must be defined.
No comments:
Post a Comment