[algogeeks] Re: Scanf in an infinite loop

2011-09-13 Thread Lakshmi Prasad
when i'm giving some character values followed by an integer the scanf
is not reading the integer

On Sep 13, 1:08 pm, Don  wrote:
> Scanf with a %d flag will ignore anything that is not a decimal
> number, until it finds a decimal number.
> Don
>
> On Sep 13, 5:23 am, Avinash Dharan  wrote:
>
>
>
>
>
>
>
> >  #include 
> > void main()
> > {
> >      while(1)
> >      {
> >         int opt;
> >         scanf("%d",&opt);
> >        printf("%d\n",opt);
> >    }
>
> > }
>
> > when i execute this program, if i give a character instead of an integer, it
> > goes into an infinite loop. why is it so?

-- 
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.



[algogeeks] Re: Scanf in an infinite loop

2011-09-13 Thread Lakshmi Prasad
could you please elaborate on this conceptor provide me with a
link

On Sep 13, 12:17 pm, Ankuj Gupta  wrote:
> What I am guessing is that the stdin used by scanf is not getting
> flushed after entering a char as a result of which it is running into
> infinite loop. If you use fflush(stdin) just after scanf it will not
> be infinite loop. But I am not able to get the reason for it.
>
> On Sep 13, 3:23 pm, Avinash Dharan  wrote:
>
>
>
>
>
>
>
> >  #include 
> > void main()
> > {
> >      while(1)
> >      {
> >         int opt;
> >         scanf("%d",&opt);
> >        printf("%d\n",opt);
> >    }
>
> > }
>
> > when i execute this program, if i give a character instead of an integer, it
> > goes into an infinite loop. why is it so?

-- 
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.



[algogeeks] Re: Puzzle

2011-08-05 Thread Lakshmi Prasad
I didn't understand it fully plese explain

On Aug 4, 2:48 pm, sagar pareek  wrote:
> double 87.5 gives you 175
> 100 will be used by 1st well and 75 will be used by second
> now second well will double the 75 and will give you 150
> 100 will be used by second and remainder 50 will forwarded to third
> now third one use 50 and will double it to 100
>
> no remainder left
> i think its clear now  :) :)
>
> On Fri, Aug 5, 2011 at 12:14 AM, Himanshu Srivastava <
>
>
>
>
>
>
>
>
>
> himanshusri...@gmail.com> wrote:
> > i mean @sagar:how did you get 87.5%??
>
> > On Fri, Aug 5, 2011 at 12:13 AM, Himanshu Srivastava <
> > himanshusri...@gmail.com> wrote:
>
> >> @nikhil:how did you get 87.5%??
>
> >> On Thu, Aug 4, 2011 at 11:59 PM, sagar pareek wrote:
>
> >>> 87.5 %
>
> >>> On Thu, Aug 4, 2011 at 10:39 PM, Nikhil Gupta  >>> > wrote:
>
>  There are 3 magical wells. Any input quantity of water we provide the
>  1st well is returned double (of this double, half is kept inside the 
>  well,
>  and the other half is used as input to the 2nd well).
>  The 2nd well also returns double the quantity of its input (of which
>  half is kept inside the well, and the other half is used as input to the 
>  3rd
>  well). Same goes with the 3rd, but its half output is the remainder 
>  (other
>  half being kept inside the well). Now what input should we provide in the
>  1st well, so that the remainder at the end comes out to be zero?
>
>  (Asked in classroom coaching of T.I.M.E.)
>  --
>  Nikhil Gupta
>  Senior Co-ordinator, Publicity
>  CSI, NSIT Students' Branch
>  NSIT, New Delhi, India
>
>   --
>  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
> >>> SAGAR PAREEK
> >>> COMPUTER SCIENCE AND ENGINEERING
> >>> NIT ALLAHABAD
>
> >>>  --
> >>> 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
> SAGAR PAREEK
> COMPUTER SCIENCE AND ENGINEERING
> NIT ALLAHABAD

-- 
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] My senior's Interview Experience at Microsoft who got selected and offered a 16lacks package

2011-08-05 Thread Lakshmi Prasad
for some inputs its giving "junk" as the answer and for others its giving 
segmentation fault 

could u plese explain why  

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/E1TOuF3IY2EJ.
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.