give answer with logic w/o running the code

Go down

give answer with logic w/o running the code

Post  ankurgutpa on Sat Aug 16, 2008 6:11 am

int a=17,b=6;
printf(&a["worst college is MNNIT Allahabad %s"],&b["IIITA is the best college"]);
cheers
avatar
ankurgutpa

Posts : 44
Join date : 2008-08-10
Age : 31
Location : Tandon 72

View user profile

Back to top Go down

i think my explaination is complete

Post  Ramprasadg on Sat Aug 16, 2008 8:23 am

  1. see printf takes the first string to use the rest of the strings
    for example
    printf("%s %s","hello","world");//displays hello world
  2. &is the address resolution operator...u can call it to be opposite of *(the pointer operator)
  3. 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... cheers
avatar
Ramprasadg

Posts : 12
Join date : 2008-08-13

View user profile

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum