I need to know how to round numbers to a certain decimal place in C++
<p>I Have this code to find out the total purchase price of some numbers and i need to know how to round the numbers to only 2 decimal places.</p>

<pre><code>#include &lt;iostream.h&gt;
#include &lt;cstdlib.h&gt;
#include &lt;string.h&gt;

int main() {
    float sale_price;
    float tax_rate;
    float discount_rate;

    system("cls");
    system("color 07");
    cout &lt;&lt; "\n\nWelcome to the second version of my total purchase price calculator!\n";
    cout &lt;&lt; "How much did your recently purchased item cost? ";
    cin &gt;&gt; sale_price;
    cout &lt;&lt; "What is the tax rate in your area? ";
    cin &gt;&gt; tax_rate;
    cout &lt;&lt; "What was the discount rate, if any (if none, just put down 1) ";
    cin &gt;&gt; discount_rate;
    float tax = sale_price*(tax_rate/100);
    float discount = sale_price*(discount_rate/100);
    float total_price = sale_price + tax - discount;
    cout &lt;&lt; "The total price of your item is $"&lt;&lt;total_price&lt;&lt;" with $"&lt;&lt;tax&lt;&lt;" tax minus $"&lt;&lt;discount&lt;&lt;" due to discount.\n";
    cout &lt;&lt; "Would you like a reciept? y or n. ";
    string answer;
    End:
    cin &gt;&gt; answer;
    if (answer == "y") {
        goto Reciept;
    }
    else if (answer == "n") {
        return 0;
    }
    else {
        cout &lt;&lt; "Try another answer\n";
        goto End;
    }
    Reciept:
    system("cls");
    system("color 70");
    cout &lt;&lt; "\xda\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xbf\n";
}
</code></pre>

<p>this usually gives me 4 decimal places just FYI</p>
