lundi 7 décembre 2020

Difference between 1./n and (double)1/n;

I am begginer with coding and i have a question.What is difference between double exp = (double)1/n, double result = pow(a,rez) and that code: ( at line 11).In my problem i need to solve geometric mean.

int main()
{

        int n, a;
        float sum = 1;
        cin >> n;

        for (int i = 0; i < n; i++)
        {
            cin >> a;
            sum *= a;
        }
        double result = pow(sum, (1.0 / n));

        //cout << result << endl;
        cout << fixed << setprecision(2) << result;

    



    

    return 0;
}

Thanks!

Aucun commentaire:

Enregistrer un commentaire