+ 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; }

14th Feb 2022, 7:36 PM
Basma M
2 Answers
+ 2
Take price as double type instead of int type. double price; or float price;
14th Feb 2022, 7:40 PM
Jayakrishna 🇼🇳
+ 2
Ok thank you so much. It worked
14th Feb 2022, 7:46 PM
Basma M