Re: [algogeeks] find the error
get() function ? On Thu, Sep 15, 2011 at 12:14 AM, rahul vatsa vatsa.ra...@gmail.com wrote: ther is no get() function. On Wed, Sep 14, 2011 at 1:55 PM, Puneet Gautam puneet.nsi...@gmail.comwrote: I think there is no problem with the while statement, even if file is not present , it will create a new file... The problem is with f.get()but dunno what...? On 9/14/11, sandeep kumar sandeep.crazyguy2...@gmail.com wrote: if file.txt is not present it gives a seg fault and if the file is present then the problem is with f.get(), use fgetc or fgets etc the program runs without any error *..* * **Regards Sandeep Kumar MTech Computer Science **IIT Madras* Music washes away from the soul the dust of everyday life - -- 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. -- 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] find the error
file not closed. On Wed, Sep 14, 2011 at 5:56 PM, ravi maggon maggonr...@gmail.com wrote: Something like this was asked in written test of Tally. We had to find the cause why this program crased during run time. File *f; int count=0; if(f=fopen(file.txt,r)) { while(f.get()!=EOF) { count++; } } -- Regards Ravi Maggon B.E. CSE, Final Year Thapar University www.algorithmguru.com *Failure is the opportunity to begin again more intelligently* -- 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. -- @ |3 # ! /\/ @ \./ -- 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] find the error
sorry fclose was also written in the last line. I missed it while asking. On Wed, Sep 14, 2011 at 6:10 PM, abhinav gupta guptaabhinav...@gmail.comwrote: file not closed. On Wed, Sep 14, 2011 at 5:56 PM, ravi maggon maggonr...@gmail.com wrote: Something like this was asked in written test of Tally. We had to find the cause why this program crased during run time. File *f; int count=0; if(f=fopen(file.txt,r)) { while(f.get()!=EOF) { count++; } } -- Regards Ravi Maggon B.E. CSE, Final Year Thapar University www.algorithmguru.com *Failure is the opportunity to begin again more intelligently* -- 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. -- @ |3 # ! /\/ @ \./ -- 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. -- Regards Ravi Maggon B.E. CSE, Final Year Thapar University www.algorithmguru.com *Failure is the opportunity to begin again more intelligently* -- 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] find the error
I guess, if file is not found, fopen will return -1. Which will evaluate the statement if(f=fopen(file.txt,r)) as true.. -- *Regards Jitesh Kumar There is only one 'YOU' in this world. You are Unique and Special.* *Don't Ever Forget it.* -- 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] find the error
if file.txt is not present it gives a seg fault and if the file is present then the problem is with f.get(), use fgetc or fgets etc the program runs without any error *..* * **Regards Sandeep Kumar MTech Computer Science **IIT Madras* Music washes away from the soul the dust of everyday life - -- 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] find the error
I think there is no problem with the while statement, even if file is not present , it will create a new file... The problem is with f.get()but dunno what...? On 9/14/11, sandeep kumar sandeep.crazyguy2...@gmail.com wrote: if file.txt is not present it gives a seg fault and if the file is present then the problem is with f.get(), use fgetc or fgets etc the program runs without any error *..* * **Regards Sandeep Kumar MTech Computer Science **IIT Madras* Music washes away from the soul the dust of everyday life - -- 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] find the error
ther is no get() function. On Wed, Sep 14, 2011 at 1:55 PM, Puneet Gautam puneet.nsi...@gmail.comwrote: I think there is no problem with the while statement, even if file is not present , it will create a new file... The problem is with f.get()but dunno what...? On 9/14/11, sandeep kumar sandeep.crazyguy2...@gmail.com wrote: if file.txt is not present it gives a seg fault and if the file is present then the problem is with f.get(), use fgetc or fgets etc the program runs without any error *..* * **Regards Sandeep Kumar MTech Computer Science **IIT Madras* Music washes away from the soul the dust of everyday life - -- 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.
Re: [algogeeks] Find the error..
What do you expect it to give ? On Wed, Jun 22, 2011 at 4:25 PM, Balaji S balaji.ceg...@gmail.com wrote: What is the wrong in this program main() { char *p,*q; p=(char *)malloc(25); q=(char*) malloc(25); strcpy(p,INDIA ); strcpy(q,hyd); strcat(p,q); printf(%s,p); } -- With Regards, Balaji.S -- 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. -- Regards Pritpal Singh Banga (RIT2008021) BTech ( IT ) , 6th Semester, Indian Institute of Information Technology Allahabad - 211012, India Official email : rit2008...@iiita.ac.in rit2008...@iiita.ac.in Mobile: +91-9793907703 -- 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] Find the error..
http://www.ideone.com/pubwV On Wed, Jun 22, 2011 at 4:30 PM, PRITPAL SINGH pritpal2...@gmail.comwrote: What do you expect it to give ? On Wed, Jun 22, 2011 at 4:25 PM, Balaji S balaji.ceg...@gmail.com wrote: What is the wrong in this program main() { char *p,*q; p=(char *)malloc(25); q=(char*) malloc(25); strcpy(p,INDIA ); strcpy(q,hyd); strcat(p,q); printf(%s,p); } -- With Regards, Balaji.S -- 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. -- Regards Pritpal Singh Banga (RIT2008021) BTech ( IT ) , 6th Semester, Indian Institute of Information Technology Allahabad - 211012, India Official email : rit2008...@iiita.ac.in rit2008...@iiita.ac.in Mobile: +91-9793907703 -- Regards Pritpal Singh Banga (RIT2008021) BTech ( IT ) , 6th Semester, Indian Institute of Information Technology Allahabad - 211012, India Official email : rit2008...@iiita.ac.in rit2008...@iiita.ac.in Mobile: +91-9793907703 -- 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] Find the error..
the only thing wrong about the program is the memory leak :p On Wed, Jun 22, 2011 at 4:30 PM, PRITPAL SINGH pritpal2...@gmail.comwrote: What do you expect it to give ? On Wed, Jun 22, 2011 at 4:25 PM, Balaji S balaji.ceg...@gmail.com wrote: What is the wrong in this program main() { char *p,*q; p=(char *)malloc(25); q=(char*) malloc(25); strcpy(p,INDIA ); strcpy(q,hyd); strcat(p,q); printf(%s,p); } -- With Regards, Balaji.S -- 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. -- Regards Pritpal Singh Banga (RIT2008021) BTech ( IT ) , 6th Semester, Indian Institute of Information Technology Allahabad - 211012, India Official email : rit2008...@iiita.ac.in rit2008...@iiita.ac.in Mobile: +91-9793907703 -- 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. -- Regards, Shachindra A C -- 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] Find the error..
@pritpal : Refer ques 5 at http://www.youthrocker.com/2011/06/interview-questions-amazon-placement.html @shachindra : wats tat :-o -- 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] Find the error..
@balaji I think memory leak is the only problem with the code. rest is fine On Wed, Jun 22, 2011 at 6:03 PM, Balaji S balaji.ceg...@gmail.com wrote: @pritpal : Refer ques 5 at http://www.youthrocker.com/2011/06/interview-questions-amazon-placement.html @shachindra : wats tat :-o -- 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. -- Regards Pritpal Singh Banga (RIT2008021) BTech ( IT ) , 6th Semester, Indian Institute of Information Technology Allahabad - 211012, India Official email : rit2008...@iiita.ac.in rit2008...@iiita.ac.in Mobile: +91-9793907703 -- 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] Find the error..
@balaji, the memory allocated from the heap using malloc needs to be released before termination of the program. there should be two additional statements as follows: free(p); free(q); On Wed, Jun 22, 2011 at 6:09 PM, PRITPAL SINGH pritpal2...@gmail.comwrote: @balaji I think memory leak is the only problem with the code. rest is fine On Wed, Jun 22, 2011 at 6:03 PM, Balaji S balaji.ceg...@gmail.com wrote: @pritpal : Refer ques 5 at http://www.youthrocker.com/2011/06/interview-questions-amazon-placement.html @shachindra : wats tat :-o -- 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. -- Regards Pritpal Singh Banga (RIT2008021) BTech ( IT ) , 6th Semester, Indian Institute of Information Technology Allahabad - 211012, India Official email : rit2008...@iiita.ac.in rit2008...@iiita.ac.in Mobile: +91-9793907703 -- 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. -- Regards, Shachindra A C -- 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] Find the error..
memory leak and memory allocation check, make sure malloc return non-null. On Wed, Jun 22, 2011 at 7:04 PM, Shachindra A C sachindr...@gmail.com wrote: @balaji, the memory allocated from the heap using malloc needs to be released before termination of the program. there should be two additional statements as follows: free(p); free(q); On Wed, Jun 22, 2011 at 6:09 PM, PRITPAL SINGH pritpal2...@gmail.com wrote: @balaji I think memory leak is the only problem with the code. rest is fine On Wed, Jun 22, 2011 at 6:03 PM, Balaji S balaji.ceg...@gmail.com wrote: @pritpal : Refer ques 5 at http://www.youthrocker.com/2011/06/interview-questions-amazon-placement.html @shachindra : wats tat :-o -- 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. -- Regards Pritpal Singh Banga (RIT2008021) BTech ( IT ) , 6th Semester, Indian Institute of Information Technology Allahabad - 211012, India Official email : rit2008...@iiita.ac.in Mobile: +91-9793907703 -- 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. -- Regards, Shachindra A C -- 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] Find the error..
@Balaji : the code given by u compiles and runs successfully in gcc compiler and gives the correct answer i.e. INDIAhyd . What's the problem ?? @Shachindra A C : Which memory leak are you talking about ?? The memory allocated from the heap using malloc need not be released before termination of the program. That's definitely not an error. The compiler does it automatically after the termination of the program... Correct me if I am wrong !! Regards, Ankit Sambyal BITS Pilani On Wed, Jun 22, 2011 at 6:34 AM, Shachindra A C sachindr...@gmail.com wrote: @balaji, the memory allocated from the heap using malloc needs to be released before termination of the program. there should be two additional statements as follows: free(p); free(q); On Wed, Jun 22, 2011 at 6:09 PM, PRITPAL SINGH pritpal2...@gmail.com wrote: @balaji I think memory leak is the only problem with the code. rest is fine On Wed, Jun 22, 2011 at 6:03 PM, Balaji S balaji.ceg...@gmail.com wrote: @pritpal : Refer ques 5 at http://www.youthrocker.com/2011/06/interview-questions-amazon-placement.html @shachindra : wats tat :-o -- 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. -- Regards Pritpal Singh Banga (RIT2008021) BTech ( IT ) , 6th Semester, Indian Institute of Information Technology Allahabad - 211012, India Official email : rit2008...@iiita.ac.in Mobile: +91-9793907703 -- 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. -- Regards, Shachindra A C -- 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] Find the error..
@Vishal : Ya this seems to be correct.. On Wed, Jun 22, 2011 at 7:05 AM, ankit sambyal ankitsamb...@gmail.com wrote: @Balaji : the code given by u compiles and runs successfully in gcc compiler and gives the correct answer i.e. INDIAhyd . What's the problem ?? @Shachindra A C : Which memory leak are you talking about ?? The memory allocated from the heap using malloc need not be released before termination of the program. That's definitely not an error. The compiler does it automatically after the termination of the program... Correct me if I am wrong !! Regards, Ankit Sambyal BITS Pilani On Wed, Jun 22, 2011 at 6:34 AM, Shachindra A C sachindr...@gmail.com wrote: @balaji, the memory allocated from the heap using malloc needs to be released before termination of the program. there should be two additional statements as follows: free(p); free(q); On Wed, Jun 22, 2011 at 6:09 PM, PRITPAL SINGH pritpal2...@gmail.com wrote: @balaji I think memory leak is the only problem with the code. rest is fine On Wed, Jun 22, 2011 at 6:03 PM, Balaji S balaji.ceg...@gmail.com wrote: @pritpal : Refer ques 5 at http://www.youthrocker.com/2011/06/interview-questions-amazon-placement.html @shachindra : wats tat :-o -- 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. -- Regards Pritpal Singh Banga (RIT2008021) BTech ( IT ) , 6th Semester, Indian Institute of Information Technology Allahabad - 211012, India Official email : rit2008...@iiita.ac.in Mobile: +91-9793907703 -- 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. -- Regards, Shachindra A C -- 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] Find the error..
As vishal pointed out, checking the return val is missing and it is the programmer's responsibility to free up the memory which he has requested for... On Wed, Jun 22, 2011 at 7:37 PM, ankit sambyal ankitsamb...@gmail.comwrote: @Vishal : Ya this seems to be correct.. On Wed, Jun 22, 2011 at 7:05 AM, ankit sambyal ankitsamb...@gmail.com wrote: @Balaji : the code given by u compiles and runs successfully in gcc compiler and gives the correct answer i.e. INDIAhyd . What's the problem ?? @Shachindra A C : Which memory leak are you talking about ?? The memory allocated from the heap using malloc need not be released before termination of the program. That's definitely not an error. The compiler does it automatically after the termination of the program... Correct me if I am wrong !! Regards, Ankit Sambyal BITS Pilani On Wed, Jun 22, 2011 at 6:34 AM, Shachindra A C sachindr...@gmail.com wrote: @balaji, the memory allocated from the heap using malloc needs to be released before termination of the program. there should be two additional statements as follows: free(p); free(q); On Wed, Jun 22, 2011 at 6:09 PM, PRITPAL SINGH pritpal2...@gmail.com wrote: @balaji I think memory leak is the only problem with the code. rest is fine On Wed, Jun 22, 2011 at 6:03 PM, Balaji S balaji.ceg...@gmail.com wrote: @pritpal : Refer ques 5 at http://www.youthrocker.com/2011/06/interview-questions-amazon-placement.html @shachindra : wats tat :-o -- 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. -- Regards Pritpal Singh Banga (RIT2008021) BTech ( IT ) , 6th Semester, Indian Institute of Information Technology Allahabad - 211012, India Official email : rit2008...@iiita.ac.in Mobile: +91-9793907703 -- 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. -- Regards, Shachindra A C -- 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. -- Regards, Shachindra A C -- 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.