give answer with logic w/o running the code

Post new topic   Reply to topic

View previous topic View next topic Go down

give answer with logic w/o running the code

Post  ankurgutpa on Sat Aug 16, 2008 12:11 pm

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

ankurgutpa

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

View user profile

Back to top Go down

i think my explaination is complete

Post  Ramprasadg on Sat Aug 16, 2008 2:23 pm

  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

Ramprasadg

Posts: 12
Join date: 2008-08-13

View user profile

Back to top Go down

View previous topic View next topic Back to top


Post new topic   Reply to topic
Permissions of this forum:
You cannot reply to topics in this forum