+ 2
How can I write the price in the following code with a comma (like 45.5...)
#include <iostream> using namespace std; int main() { int ages[5]; for (int i = 0.0; i < 5.0; ++i) { cin >> ages[i]; } //your code goes here int min=ages[0]; for (int i =0.0; i<5.0; ++i){ if ( ages[0] < min){ min = ages [i]; } } int price; price = 50.0 - ( 50.0 * min/100.0); cout << price << endl; return 0; }
2 odpowiedzi
+ 2
Take price as double type instead of int type.
double price;
or
float price;
+ 2
Ok thank you so much. It worked