@Vindhya every time least is getting 101-'e' as the value. and not llo as the statement least = (*ptr<least ) ?(*ptr) :(least);
is equivalent to if(*ptr<least) least=*ptr; so firstly it compares 127 with 'e' and least ='e' in next iteration , it compares l and e, so agn least = 'e' in next iteration , it compares l and e, so agn least = 'e' in next iteration , it compares o and e, so agn least = 'e' in next iteration , it compares null and e, so least = 0 i hope this will clarify your doubts On Sun, Jul 15, 2012 at 11:57 PM, vindhya chhabra <[email protected]>wrote: > please someone explain > > > On Sun, Jul 15, 2012 at 3:54 PM, vindhya chhabra <[email protected] > > wrote: > >> #include <stdio.h> >> main() >> { >> char * str = "hello"; >> char * ptr = str; >> char least = 127; >> while (*ptr++) >> least = (*ptr<least ) ?(*ptr) :(least); >> printf("%d",least); >> getch(); >> } >> in this ques i got o/p is 0(no doubt) but i have a doubt in why every >> time least is getting 101-'e' as the value. why are ascii values of llo not >> assigned in least. please someone explain. >> -- >> Vindhya Chhabra >> >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > > > -- > Vindhya Chhabra > > > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
