[algogeeks] GATE 2011 C Ques

2011-07-02 Thread KK
10. What does the following fragment of C-program print?

char c[] = GATE2011;
char *p =c;
printf(%s, p + p[3] - p[1]);

 (A) GATE2011 (B) E2011 (C) 2011 (D) 011
Answer: - (C)

why is p[3] - p[1] returning 4 

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] GATE 2011 C Ques

2011-07-02 Thread abhijith reddy
p[3] = 'E'
p[1] = 'A'
p[3]-p[1] = 4
?

On Sat, Jul 2, 2011 at 7:10 PM, KK kunalkapadi...@gmail.com wrote:

 10. What does the following fragment of C-program print?

 char c[] = GATE2011;
 char *p =c;
 printf(%s, p + p[3] - p[1]);

  (A) GATE2011 (B) E2011 (C) 2011 (D) 011
 Answer: - (C)

 why is p[3] - p[1] returning 4 

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] GATE 2011 C Ques

2011-07-02 Thread sameer.mut...@gmail.com
ASCII value of 'A' is 65 and Asciivalue of 'E' is 69.
69-65=4

On Sat, Jul 2, 2011 at 7:12 PM, abhijith reddy abhijith200...@gmail.comwrote:

 p[3] = 'E'
 p[1] = 'A'
 p[3]-p[1] = 4
 ?


 On Sat, Jul 2, 2011 at 7:10 PM, KK kunalkapadi...@gmail.com wrote:

 10. What does the following fragment of C-program print?

 char c[] = GATE2011;
 char *p =c;
 printf(%s, p + p[3] - p[1]);

  (A) GATE2011 (B) E2011 (C) 2011 (D) 011
 Answer: - (C)

 why is p[3] - p[1] returning 4 

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.