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 amount = 19.35;
double amount = 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 numberDollar=20;
double numberPennyStamps= numberDollar - 0.5;
cout<<numberPennyStamps<<"\n";
double amount1 = 19.35;
double amount2 = 19.95;
int a = amount2;
int b = amount2 + 0.5;
cout<<"a = "<<a<<"\n";
cout<<"b = "<<b<<"\n";
return 0;
}
Output:
a = 19
b = 20
Comments
Leave a comment