Question: When you run this program, it prints 4 3 4 as the value of cents: double price = 4 . 3 5 ; int cents

When you run this program, it prints 434 as the value of cents: double price =4.35; int cents =100* price; // Should be 100*4.35=435 cout << cents << endl; // Prints 434! What is the probable reason? Question 20 options: A roundoff error occurs with (binary) floating point variable values. When double values are assigned to ints, any fractional part is dropped. Both of options are correct. Neither option is correct.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!