According to K&R the behavior of printf is undefined if u do not use correct format specifiers for the variables. --
Amol Sharma Third Year Student Computer Science and Engineering MNNIT Allahabad <http://gplus.to/amolsharma99> <http://twitter.com/amolsharma99><http://in.linkedin.com/pub/amol-sharma/21/79b/507><http://www.simplyamol.blogspot.com/> <http://youtube.com/amolsharma99> On Mon, Jan 9, 2012 at 11:01 AM, atul anand <atul.87fri...@gmail.com> wrote: > take care when ever you use %d and %f > > %d is not flexible in handling float varibale....do not expect it to > typecast itself. > reason could be , you are trying to fit large data type i.e float to the > int whose range is less. > > whereas in second case float can incorporate int type , so automatic > typecasting is done. > > > On Mon, Jan 9, 2012 at 10:17 AM, HARSHIT PAHUJA > <hpahuja.mn...@gmail.com>wrote: > >> *#include<stdio.h> >> int main() >> { >> float f=25.25; >> printf("%d\n",f); >> long int x=90; >> printf("%f",x); >> return 0; >> } >> * >> >> above program gives output >> *0 >> 25.250000* >> >> shudn it be : >> *25 >> 90.0000* >> ?? >> >> -- >> 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.