give answer with logic w/o running the code
2 posters
Page 1 of 1
give answer with logic w/o running the code
int a=17,b=6;
printf(&a["worst college is MNNIT Allahabad %s"],&b["IIITA is the best college"]);
printf(&a["worst college is MNNIT Allahabad %s"],&b["IIITA is the best college"]);
ankurgutpa- Posts : 44
Join date : 2008-08-10
Age : 36
Location : Tandon 72
i think my explaination is complete
- see printf takes the first string to use the rest of the strings
for example
printf("%s %s","hello","world");//displays hello world - &is the address resolution operator...u can call it to be opposite of *(the pointer operator)
- a[b]is interpreted as *(a+b)
so
&a["worst college is MNNIT Allahabad %s"] is interpreted as "MNNIT Allahabad %s" as a=17
&b["IIITA is the best college"] is interpreted as "is the best college" as b=6
so on the whole it is
printf("MNNIT Allahabad %s" ,"is the best college");
no wonder MNNIT IS THE BEST COLLEGE...nice question Ankur...
Ramprasadg- Posts : 12
Join date : 2008-08-13
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum