Re: [algogeeks] C ouput

2011-07-25 Thread private.joker
#includestdio.h int main() { int a[5] = {1,2,3,4,5}; int *p = a; p=p+1;; printf(%d,*(p)); getch(); return 0; } After p=p+1, p should point to the next byte after 5, but output in this case 2. That is p is just travelling inside the array. Is thr any diff b/w

Re: [algogeeks] C ouput

2011-07-25 Thread private.joker
I guess I got that. (a + 1) increments the pointer to the array(a here) according to the size of array where as p, being a pointer to an int gets incremented by the size of int(4 byte in 32 bit compiler) with the statement p = p+1 Correct me if i am wrong. -- You received this message because

Re: [algogeeks] C ouput

2011-07-25 Thread sameer.mut...@gmail.com
On 7/25/11, private.joker abhi123khat...@gmail.com wrote: I guess I got that. (a + 1) increments the pointer to the array(a here) according to the size of array where as p, being a pointer to an int gets incremented by the size of int(4 byte in 32 bit compiler) with the statement p = p+1

Re: [algogeeks] C ouput

2011-07-24 Thread sagar pareek
@ambika 20 questions of MCQ with negative marking mostly C/DS then 1-2 que of OS then puzzle and apti 2 questions of programming longest increasing subarray and spiral matrix printing On Sat, Jul 23, 2011 at 8:30 PM, Akshata Sharma akshatasharm...@gmail.comwrote: Thanks all :) its clear now..

Re: [algogeeks] C ouput

2011-07-24 Thread ambika iyer
@sagar : thnx !!! On Sun, Jul 24, 2011 at 1:44 PM, sagar pareek sagarpar...@gmail.com wrote: @ambika 20 questions of MCQ with negative marking mostly C/DS then 1-2 que of OS then puzzle and apti 2 questions of programming longest increasing subarray and spiral matrix printing On Sat,

[algogeeks] C ouput

2011-07-23 Thread Akshata Sharma
main() { int a[5] = {1,2,3,4,5}; int *ptr = (int*)(a+1); printf(%d %d , *(a+1), *(ptr-1) ); } output: 2 5 can someone please exlplain how we are getting 5? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send

Re: [algogeeks] C ouput

2011-07-23 Thread Amol Sharma
a denotes the address of array a+1 increments a by size of array and stores in ptr.i.e. ptr points to end of array hence ptr-1 will print 5 -- Amol Sharma Third Year Student Computer Science and Engineering MNNIT Allahabad On Sat, Jul 23, 2011 at 6:03 PM, Akshata Sharma

Re: [algogeeks] C ouput

2011-07-23 Thread sagar pareek
that question was just asked by amazon in mnnit :) On Sat, Jul 23, 2011 at 6:10 PM, Amol Sharma amolsharm...@gmail.com wrote: a denotes the address of array a+1 increments a by size of array and stores in ptr.i.e. ptr points to end of array hence ptr-1 will print 5 -- Amol Sharma

Re: [algogeeks] C ouput

2011-07-23 Thread sukhmeet singh
Amazon ..!! :) a increments by whole array not just an int value..!! u marked 2 1 ?? On Sat, Jul 23, 2011 at 6:03 PM, Akshata Sharma akshatasharm...@gmail.comwrote: main() { int a[5] = {1,2,3,4,5}; int *ptr = (int*)(a+1); printf(%d %d , *(a+1), *(ptr-1) ); } output: 2 5 can

Re: [algogeeks] C ouput

2011-07-23 Thread sukhmeet singh
same here in IIIT !! :P On Sat, Jul 23, 2011 at 6:15 PM, sagar pareek sagarpar...@gmail.com wrote: that question was just asked by amazon in mnnit :) On Sat, Jul 23, 2011 at 6:10 PM, Amol Sharma amolsharm...@gmail.comwrote: a denotes the address of array a+1 increments a by size of

Re: [algogeeks] C ouput

2011-07-23 Thread Manish Kumar
@Akshata: Whenever you increase any variable then it increases according to its type. Here the address of array 'a' is being increased.( a+1 ). so the address of 'a' will temporarily increased to 20 bytes and then that is assigned to ptr. so ptr is now pointing to any value in the memory just

Re: [algogeeks] C ouput

2011-07-23 Thread radha krishnan
same question in MS written :P On Sat, Jul 23, 2011 at 5:49 AM, Manish Kumar manish.monu...@gmail.com wrote: @Akshata: Whenever you increase any variable then it increases according to its type. Here the address of array 'a' is being increased.(  a+1 ). so the address of 'a' will temporarily

Re: [algogeeks] C ouput

2011-07-23 Thread ambika iyer
@sagar : what was the question paper pattern for amazon On Sat, Jul 23, 2011 at 6:32 PM, radha krishnan radhakrishnance...@gmail.com wrote: same question in MS written :P On Sat, Jul 23, 2011 at 5:49 AM, Manish Kumar manish.monu...@gmail.com wrote: @Akshata: Whenever you increase

Re: [algogeeks] C ouput

2011-07-23 Thread Akshata Sharma
Thanks all :) its clear now.. On Sat, Jul 23, 2011 at 6:37 PM, ambika iyer balu200...@gmail.com wrote: @sagar : what was the question paper pattern for amazon On Sat, Jul 23, 2011 at 6:32 PM, radha krishnan radhakrishnance...@gmail.com wrote: same question in MS written :P On Sat,