+ 1
How to get decimal points in my output in this case?
https://code.sololearn.com/cx73vOe9Y1e5/#cpp I want the program to give me answer in points but it is not. It is not doing so and rounding it off.
2 Respostas
+ 9
E.g.
#include <iostream>
#include <iomanip>
int main() {
double height, base, area;
std::cin >> height >> base;
std::cout << std::setprecision(2) << std::fixed;
std::cout << "The area of the triangle is " << base*height/2;
return 0;
}
+ 8
Variables should be "double" or "float", not "int".