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


About Karim Shah's Blog Life is what we expect from it

An energetic and optimistic person who always looks at life with hope and courage. Strongly believe in everything happens for a reason and for good. Life is what you dream of it. Every situation is what you give meaning to it. There is nothing as such existing except what we give meaning to it.
This entry was posted in Experience Based Solutions. Bookmark the permalink.

Leave a Reply

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

You are commenting using your 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