[algogeeks] Re: c program

2011-08-28 Thread rahul sharma
plz expalin char*f= On Aug 28, 11:12 am, Piyush Grover piyush4u.iit...@gmail.com wrote: it's a quine problem. char*f=char*f=%c%s%c; main(){ printf(f,34,f,34,10);}%c; main() { printf(f,34,f,34,10); } I have used whitespaces to make it understand. On Sun, Aug 28, 2011 at

[algogeeks] Re: c program

2011-08-28 Thread rahul sharma
i m not able to understand hw it wokrs..elaborate it On Aug 28, 11:16 am, rahul sharma rahul23111...@gmail.com wrote: plz expalin char*f=             On Aug 28, 11:12 am, Piyush Grover piyush4u.iit...@gmail.com wrote: it's a quine problem. char*f=char*f=%c%s%c; main(){

Re: [algogeeks] Re: c program

2011-08-28 Thread Piyush Grover
char*f=char*f=%c%s%c;main(){printf(f,34,f,34,10);}%c; f is a global pointer to the char array which contains the string char*f=%c%s%c;main(){printf(f,34,f,34,10);}%c Now in main function you are printing this string with arguments 34,f,34,10. ASCII value of is 34. -So in f, the first %c is

[algogeeks] Re: c program

2011-08-28 Thread rahul sharma
got it...thnkx On Aug 28, 11:31 am, Piyush Grover piyush4u.iit...@gmail.com wrote: char*f=char*f=%c%s%c;main(){printf(f,34,f,34,10);}%c; f is a global pointer to the char array which contains the string char*f=%c%s%c;main(){printf(f,34,f,34,10);}%c Now in main function you are printing this

[algogeeks] Re: c program

2011-08-28 Thread rahul sharma
this logic is ok...but we have pre defined everything in char f...if i add one or two more statements then it will require corresponding change in char *f...can i open the same file with f open n prin t it out? On Aug 28, 11:31 am, Piyush Grover piyush4u.iit...@gmail.com wrote:

Re: [algogeeks] Re: c program

2011-08-28 Thread Piyush Grover
yeah you can do that by opening the file and printing it but as far as I know, interviewer adds the constraint of not using the file method. On Sun, Aug 28, 2011 at 12:35 PM, rahul sharma rahul23111...@gmail.comwrote: this logic is ok...but we have pre defined everything in char f...if i add

Re: [algogeeks] Re: c program

2011-08-28 Thread UTKARSH SRIVASTAV
good logic On Sun, Aug 28, 2011 at 12:14 AM, Piyush Grover piyush4u.iit...@gmail.comwrote: yeah you can do that by opening the file and printing it but as far as I know, interviewer adds the constraint of not using the file method. On Sun, Aug 28, 2011 at 12:35 PM, rahul sharma

Re: [algogeeks] Re: c program

2011-08-28 Thread aditya kumar
one more method : use system funtion . eg system(cat filename) //system funtion executes the command On Sun, Aug 28, 2011 at 1:51 PM, UTKARSH SRIVASTAV usrivastav...@gmail.comwrote: good logic On Sun, Aug 28, 2011 at 12:14 AM, Piyush Grover piyush4u.iit...@gmail.com wrote: yeah you can

Re: [algogeeks] Re: c program

2011-08-28 Thread saurabh singh
Well if you go on using system calls functions etc the job can easily be done in many ways but the real idea behind the quine problem is the good old spirit of a challenge (not merely for an interview) So the best way remains the store everything way... On Sun, Aug 28, 2011 at 3:11 PM, aditya

Re: [algogeeks] Re: c program

2011-08-28 Thread aditya kumar
yes i agree since in the question they dint mention so we can solve it the other way also . On Sun, Aug 28, 2011 at 7:31 PM, saurabh singh saurab...@gmail.com wrote: Well if you go on using system calls functions etc the job can easily be done in many ways but the real idea behind the quine

[algogeeks] Re: c program output

2011-02-07 Thread Dave
@Ankit: The variable a is a float, while the constant 11.202 is a double. When the constant 11.202 was rounded to size float in the assignment, it was (apparently) rounded down. For purposes of the comparison, a was cast to type double, and the added bits were filled with zeros. So (double)a

[algogeeks] Re: c program output

2011-02-07 Thread Dave
@Shalini: Did you try it, or are you only speculating? Dave On Feb 7, 9:02 am, Shalini Sah shalinisah.luv4cod...@gmail.com wrote: try dis : #includestdio.h int main() {     float a=11.202;     if((a-11.202)==0)                 printf(Hiii!!!\n);     else         printf(Hello!!!\n);    

[algogeeks] Re: c program output

2011-02-07 Thread Dave
@Rajeevpodar: Float comparisons are fine, if you do them correctly. In this case, using 11.202e0 instead of 11.202 is correct. And, of course, your comparison is not an one-sided inequality test, but a fuzzy equality test. Dave On Feb 7, 9:14 am, Rajeevpodar rajeevpo...@gmail.com wrote: Float

Re: [algogeeks] Re: c program output

2011-02-07 Thread Shalini Sah
i tried it n its running On Mon, Feb 7, 2011 at 8:53 PM, Dave dave_and_da...@juno.com wrote: @Shalini: Did you try it, or are you only speculating? Dave On Feb 7, 9:02 am, Shalini Sah shalinisah.luv4cod...@gmail.com wrote: try dis : #includestdio.h int main() { float

[algogeeks] Re: c program output

2011-02-07 Thread Dave
@Ankit: Yes. The bug is that the constant in the comparison should have been written 11.202e0. Dave On Feb 7, 9:05 am, ankit agarwal ankitgeniu...@gmail.com wrote: But is the bug in the given program On Mon, Feb 7, 2011 at 8:32 PM, Shalini Sah shalinisah.luv4cod...@gmail.com wrote:

Re: [algogeeks] Re: c program output

2011-02-07 Thread ankit agarwal
Thanq ol... On Mon, Feb 7, 2011 at 8:56 PM, Dave dave_and_da...@juno.com wrote: @Ankit: Yes. The bug is that the constant in the comparison should have been written 11.202e0. Dave On Feb 7, 9:05 am, ankit agarwal ankitgeniu...@gmail.com wrote: But is the bug in the given program