Rounding Numbers - Thank You

Hi all I'm new to the forum and new to C++. I have a problem that I solved but could not round it to a whole number as required. Can someone please help? I'd really appreciate it.


#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main()

{
double area, diameterInInches, numberOfSlices, radius;

//This program calculates the number of slices in a pizza... Get the diameter in inches.
cout << "What is the diameter of the pizza in inches? ";
cin >>diameterInInches;

// calculate number of slices.
cout << "The number of slices in this pizza are: ";
radius = diameterInInches / 2;
area = 3.14 * pow(radius, 2);
numberOfSlices = area / 14.125;

cout << numberOfSlices << endl;

cout << endl;
system ("pause");
return 0;
}


I've seen that and tried to figure it out, but I do not know how to incorporate rounding numbers into my code. Do you know how?

Thank You for your quick response.
Look through the article and code and use the rounding algorithm you need. If all you want is common rounding then use the roundhalfup() function.

Glad to be of help.
I'm not sure how to use the code. I tried a few different options and failed. I provided the code above so that someone can incorporate "round up" into it, so that I can study what they did to the code and learn from it.

Thank You...
Topic archived. No new replies allowed.