Sie sind auf Seite 1von 8

char **p=&"abcd"; is same as

char *p=&"abcd";
printf("%d",3&2); will give 2
printf("%d",4&3); will give 3
(n!)&n will give "#tp#t as n
3$$2 here %!! bec"mes %%%
n$$i this is same as n&(2'i)
f"r p"sitive n#mbers its fl""r
f"r (ve n#mbers its ceil
n))i this is same as n*(2'i)
this is same f"r b"th p"sitive an d*ve n#mbers e+cept f"r the (ve sign
if(i && ,) ver- imp"rtant pitfall
remember c"mpiler design bac. paching
since here the c"nditi"n bec"mes false with /i0 the rest "f the if statement d"es n"t
2" at the end i=% and ,=! "nl-1
3his d"es n"t sh"w an- err"r
ret#rn !%;
ret#rn !%%; && warning5 #nreachable c"de
printf("%d",i'i); is 789
static int abc() && this static has n" effect
int i=!;
ret#rn i;
int a:!%%;;
a; && this is an err"r f"r arra-
int i
i; && this w"r.s
f"r(i=%; i )= !% ; i,printf("%d",i)); && this is n"t an err"r an- t-pe "f a st can be
ascii val#es 4<*=> is n#mber fr"m %*?
int @==3@=%
int 32>@<=*32>@<
fl"at siAe=4
d"#ble siAe=<
l"ng d"#ble = !%
char a;
char b;
char c;
char d;
6car; && the siAe "f this #ni"n is !
char i;
char ,;
6in; && similarl- siAe "f this is !
char A; && the siAe "f this #ni"n is !
6pBr; &&th#s the siAe "f this #ni"n is !
4int i;
i = =;
printf("%d111",i);6 &&here i==&&
printf("%d",i); &&here i=!%&&
main() && this is a c"rrect pr"gram
n"te in p"inters
int *i,,=!%;
then i=*&i=&*i=&,
str#ct +-A4
int i;
str#ct +-A *p;
p*$i = !%;
printf("%d",*p1i);&& this is wr"ng
printf("%d",(*p)1i); &&this is c"rrect
(*main)(); && can be #sed t" call main() b"th are same
b- defa#lt the val#es "f the variables inside str#ct and #ni"n are initialiAed t"
garbage val#es
4str#ct +-A4
int i;
str#ct +-A *p;
str#ct +-A a = 4%6;
*p =a; && this means val#e at address in p is a
p*$i = !%; &&this is a different reference
printf("%d",a1i); 6
str#ct +-A4
int i;
str#ct +-A +-A; && n"te the same str#ct name can be #sed as name "f variable
+-A1i = !%;
scanf "r printf can be #sed as a variable name and their get redefined and will bec"me a
n"n f#ncti"n
str#ct fprintf 4
int i;
int fprintf; && this is n"t an err"r && redeclarati"n is all"wed
char fprintf; && this again is wr"ng
same name cann"t be #sed f"r b"th #ni"n and str#ct in same sc"pe
same name can be given declared in diffenet sc"pes1
C&rC carries the c#rs"r t" the beginig "f the line
printf("DnEe%cll"",!3);&& hre n"thing bef"re %c is printed
printf("DnEe%c",!3); && "&p = Ee
printf("Dn%cll"",!3); && "&p = cll"
ll""); &* Frr"r*&
nll""); &*will w"r.*&
if given
Gdefine vmci "+-A"; int i=%;
the wh"le sentence is ta.en as pre pr"cess"r dir
if we declare certain variables the- are p#shed "nt" a 23HIJ and are p"pped "#t when
printf(C%dK%dL); is given
this is tr#e "nl- when given inside the same f#ncti"n
if given in s"me "ther fn "nl- garbage is prited1
Mn case "f a f#ncti"n declarati"n and #sage the s-nta+ "f the place "f declarati"n and
calling is "nl- c"mpared that t"" "nl- the parameter is chec.ed and it ma- "r ma- n"t
accept the ret#rn val#e1
Mnt abc(int);
Hbc(); &&will w"r.
Mn s-stem all p"sitive n#mbers are st"red in their same f"rm
% is st"red as %%%%%%%%%%%%%%%%
when i=N% then its val#e bec"mes !!!!!!!!!!!!!!!!
when as.ed t" print with %d then it sees the first ! and then the 20s c"mplement
"f the rest which is %%%%%%%%%%%%%!
th#s the "#tp#t is *!
similarl- N!=*2 N2=*3
char a:=**2&2; =4OaO,ObO,OvO,OdO,OeO6;
char a:*=; =4OaO,ObO,OvO,OdO,OeO6;
char a:2%;; in all the cases an err"r will be sh"wn telling that an arra- m#st have
atleast "ne element
NOTE: when ever there is a mismatch in parameters in the f#ncti"n call the val#es are
ta.en t" be Aer"1 3he parameter that matches the datat-pe the sent val#e1
Mn case there is a mismatch in the datat-pe then the val#e is ta.en is Aer"1
Eere again t-pe cast "cc#rs fr"m char t" int n"t fr"m int t" char1
Ppcasting "cc#rs b#t d"wn casting d"es n"t "cc#r1
NOTE: d#ring a f#ncti"n call "nl- the declarati"n ret#rn t-pe and calling place ret#rn
t-pe are c"mpared that t"" "nl- f"r /v"id01 Mt never b"thers ab"#t the fn definiti"n1
if its declated v"id then it cann"t be assigned t" an- variable in the calling place
NOTE: ret#rn; and ret#rn %; b"th are same
NOTE: v"latile c"nst int a;
a=!%; && F9989
c"nst v"latile int a;
a=!%; && F9989
NOTE: f"r(; i)=!% ; if(i==!!);)
there cann"t be an- l""p "r c"nditi"nal statements inside f"r and n" third semic"l"n
Gincl#de )stdi"1h,d"s1h$ &* Mt w"nOt c"mpile in HQ2M I *&
NOTE:prepr"cess"r directives can als" be given inside an- f#ncti"n
Gdenfine ddd CaaaL
!1 main()
Gdefine ddd Caaa dddL; &&this will n"t sh"w an- err"r
21 main()
Gdefine ddd CaaaL &&n" err"r
21 main()
Gdefine ddd Caaa dddL; && err"r5 redeclarati"n n"t identical
printf(C%sL,ddd); && "nl- when # have a #sage this pr"blem "cc#rs
char *p="Eell"";
printf("%c",p:%;); &&will w"r.
int i;
i = !%; &* Re canOt assign an- val#e in gl"bal space =$ Frr"r*&
NOTE: char *p;
p = "%dDn";
p; &&will w"r.
Gifdef STIM && this is the gl"bal wa- "f declaring the if11 statement
int i = !%;&& this is e+ec#ted if STIM is Gdefined c"nst variable
als" if s"me "ther val#e is given f"r /i0 inside the pr"gram its "verwritten
Gifdef ! && will w"r.
int i = !%;
NOTE:Gdefine STIM && giving "nl- this with"#t giving an- val#e t" it is an err"r it
ass#mes f#ll "f spaces
NOTE: f"r(i = *!%; i)= *! ; i**)
printf("%d",i); &* Mnfinite l""p *&
f"r(i = *!%; i)= *! ; i)
printf("%d",i); &* Mnfinite l""p *&
NOTE: if an- str#ct is declared gl"bal then
***there need n"t be an- ; given even given n"t an err"r
***if declared inside an- fn then ; is c#mp#lsar-
NOTE: H /v"id0 is a datat-pe that is #sed t" declare "nl- p"inters and n"t variables
beca#se its siAe is #n.n"wn1 H p"inter "f t-pe /v"id0 can be declared beca#se its
"bvi"#s that its g"in t" c"ntain "nl- #nsigned int1 it can h"ld the address "f an- "ther
datat-pe variable1
Restrictions: a v"id p"inter cann"t be dereference ie1 its val#e cann"t be accesses
#sing /*0
a v"id p"inter cann"t be manip#lated
NOTE: char a:4; = 4O+O,O-O,OAO,4=@4=@6; is c"rrect assignment
NOTE: v"id (*b)(int *);
b is p"inter t" a f#ncti"n which
a p"inter t" an int and ret#rns a v"id
NOTE: char a = OHUO;
printf("%c",a); &&prints "nl- /H0
NOTE: int * p:; ;
int (*p):;;&& b"th p0s are an arra- "f p"inter t" integer
NOTE: when e+tern variables are declared "#tside b#t n"t assigned an- val#e and if that
variable is #sed inside its err"r1
(eg)e+tern int i;
4 printf("%d",i); 6 &&F99895 #ndefined s-mb"l /i0
b#t if its defined aswell "#tside then its n"t err"r
e+tern int i=!%%;
4 printf("%d",i); 6 &&will w"r.
NOTE: Extern are b- defa#lt declared %
Rhen declared inside an- f#ncti"n as /e+tern0 it cann"t be initialiAed ie e+tern int
i=!%; &* err"r *&
8r even ,#st this statement is err"r1 3he variable /i0 m#st have a gl"bal declarati"n
NOTE: auto .e-w"rd can be #sed "nl- f"r l"cal variables
register int i; &* F9989 5 9egister variable ma- n"t be Vl"bal WWWWWW *&
NOTE: "%l" is wr"ng
"%ld" is right
NOTE: when # declare a variable as /register0 then /&0 "perat"r can"t be #sed with it it
m#st ta.e a m&- l"cati"n t" access #sing /&0
NOTE: static declarati"n is n"t gl"bal declarati"n b#t can be declared in gl"bal regi"n
NOTE: p = "Eell"","w"rld"; &&p is assigned Chell"L
NOTE: p="Eell"" "w"rld"; &&p is assigned Chell"w"rld"
????? what is \v ?????????????????????????
NOTE: p = "hell"";
printf("%13s",p); && will print /hel0
NOTE: f"r l"ng #nsigned integer the t-pe identifier is C%l#L and n"t C%#lL
NOTE: Ihar is till 2== and 2=@=%
NOTE: her divide by 0 is ,#st a warning
NOTE: 3 is err"r beca#se 3 is a c"nstant
NOTE: .p here is ass"ciated with "nl- /.0
., is wr"ng
. , will w"r.
NOTE:d#ring initialiAati"n this is c"rrect
int i = 2;
int i= 2; && b"th are c"rrect
Mnt M =2 is wr"ng
int i =* *2;&& i is n"w 2
int i =* 2;&& i is n"w *2
int i =* * *2;&&i is n"w *2
NOTE: with in if() statement n" c"nditi"nal statements can be given ie1 if, while,
f"r, etcK
NOTE: arra- s#bstript m#st alwa-s be a c"nst d#ring declarati"n
NOTE: switch i
Xi.e this switch is err"r
NOTE: Gdefine int H
Gdefine H int
Mn this pr"gram first the first directive is c"mpletel- replaced then again d#ring the
sec"nd r"#nd chec. the sec"nd directive is implemented1
NOTE: int i = 4 @!2 6;&& this is als" c"rrect declarati"n
NOTE: this .ind "f declarati"n is c"rrect
str#ct nnn 4
char a:!%;;
int i;
str#ct nnn aaa:; = 4"hell"",!%,"b-e",2%6;
here aaa:%; and aaa:!; are a#t"maticall- declared
NOTE: declaring the f"ll"wing wa- is c"rrect
d"#ble l"ng a;
l"ng d"#ble a;
NOTE:Gifndef STIM && here n"te that CifndefL
Gerr"r M l"ve STIM && irrespective "f the c"de this is pr"mpted as err"r if STIM
Gendif is n"t defined
NOTE: Gifndef ! &&cann"t be #sed
NOTE: if a variable is declared as
#nsigned Mnt i=*2; here /i0 is ta.en as *2 "nl- in all the c"p#tati"ns even in
c"nditi"nal statements
NOTE: en#m I8X8924UXHIJ=?,UXPF,V9FFQ6;
in this case bl#e=!% and green=!! are assigned a#t"maticall-
NOTE: printf("%<sDn",p); && this is #sed f"r printing in an "rderl- fashi"n li.e
??? && in this allignmenet the t"tall- %=d will d" this
whats with !ve nu"ber ?????????????????????????????
NOTE:printf("%1*s",4,p); &&prints first 4 chars n" "ther c"mbinati"n w"r.s
NOTE: how conversion bw dataty#es occurs
NOTE: int i = %+24; && this is an err"r
NOTE: variable name length m#st be )=32
NOTE:&i = &i !%;&& err"r Xval#e reB#ired
NOTE: int *p = "Eell"";
int *A;
printf(C%sL,A); && prints ,#n.
NOTE: alwa-s the parameters t" a f#ncti"n call is passed fr"m left t" right;
Eere sec"nd i is passed first and the first is passed sec"nd1
NOTE:prepr"cess"r is message t" the c"mpiler n"t t" the lin.ers