The following mathematical expression is used to find the number of penny stamps one gets if one inserts dollars number of dollars in a stamp vending machine that returns the change in penny stamps. Replace the given mathematical expression by a simpler expression that gives the same value.
double amount1 = 19.35;
double amount2 = 19.95;
What are values of variables a and b after the following assignments?
int a = amount2;
int b = amount2 + 0.5;
#include <iostream>
using namespace std;
int main()
{
double amount1 = 19.35;
double amount2 = 19.95;
cout << "amount1 = " << amount1 << endl;
cout << "amount2 = " << amount2 << endl;
int a = amount2;
int b = amount2 + 0.5;
cout << "int a = 19.95 =: " << a << endl;
cout << "int b = 19.95 + 0.5 =: " << b << endl;
return 0;
}
Comments
Leave a comment