Here is my code, it is suppose to take the double num, round it, and return it using call by reference, but when i try to compile it gives me an ambiguity error at round(i); .

please help.

#include <iostream>
#include <cmath>
using namespace std;

void round(double &num);
int main()
    string line;
    double i = 100.7;
    cout << "Number i before rounding: " << i << "\n";
    cout << "Number i after rounding: " << i << "\n";
    double j = -3.3;
    cout << "Number j before rounding: " << j << "\n";
    cout << "Number j after rounding: " << j << "\n";
    return 0;

void round(double &num)
     int value;
     int fraction;
     fraction = modf(num, &value);
     if(fraction < 0.5) num = value;
     else num = value + 1;

line 30: modf() takes pointers to two doubles. value is not a double. And it returns a double, not an integer. Please read the documentation for functions you use.

Thanks, I was able to solve it by changing the function to void round(double *num) and the call to round(&i)