Things to Ponder!

I wrote a code in C++ to get an distance as feet and inches from the user where the feet is declared as type int and inches as float data type.

I test it and run fine.

Then an idea came to me to see if it accepts feet in other than int and I gave feet as floating point and here are the crazy result it is giving.

With feet as int and inches as float

 

 

 

 

 

 

 

 

 

 

when I give the feet as float then it not even accepts inches and prints the option if i want to give other input or terminate. But when I end it by pressing ‘y’ then i saw something crazy. it separated the integer and fractional part and assigned the fraction part to inches. See the figure below

With feet as float

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s