Computer Club MNNIT
Would you like to react to this message? Create an account in a few clicks or log in to continue.

give answer with logic w/o running the code

2 posters

Go down

give answer with logic w/o running the code Empty give answer with logic w/o running the code

Post  ankurgutpa 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
ankurgutpa
ankurgutpa

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

Back to top Go down

give answer with logic w/o running the code Empty i think my explaination is complete

Post  Ramprasadg 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
Ramprasadg
Ramprasadg

Posts : 12
Join date : 2008-08-13

Back to top Go down

Back to top

- Similar topics

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