i am trying to mod my input
but i got an error :
invalid operands of types 'double' and 'int' to binary 'operator%'
i would also like to noe top/60 how do i not show the remainder.
i am using dev c++

this is my code :

int main()
{
    double DriverLapTime[3][3] = {};
    double minutes, seconds;
    string WheelSet[3] = {"Bridgestone","Michelin","Dunlop"};
    
    for (int i = 0; i < 3; i++) {
    cout << "Lap time for driver " << i+1 << endl;
        for (int j = 0; j < 3; j++) {
        cout << "Lap 1 (Wheel Set " << j+1 << ") : ";
        cin >> minutes >> seconds;
        DriverLapTime[i][j] = (minutes * 60) + seconds; }
    cout << endl;
        }
        
    cout << fixed << setprecision(2);

    top = DriverLapTime[0][0];
    for (int a = 0; a < 3; a++) 
        for (int b = 0; b < 3; b++)
        if ( DriverLapTime[a][b] > top )
           top = DriverLapTime[a][b];

    
    cout << top / 60 << " minutes " << top % 60 << " seconds ";
        
    return 0;
}

The remainder operator doesn't work with floating-point types. Look up the fmod function in <cmath> for getting the remainder of floating-point division.

thanks for the help!
is there any to not show the remainder of a division?

thanks for the help!
is there any to not show the remainder of a division?

Yes. If you want a better answer, you are going to have to ask a more precise question.

i would like to display the output ot (top / 60) without the remainder and no rounding too.

>i would like to display the output ot (top / 60) without the remainder and no rounding too.
That's two questions. You want to divide a floating-point value (just use the division operator, that works) and you want to display the value without rounding. The easiest way to do that (if you can manage it) is to increase the displayed precision such that cout doesn't round the value for you:

#include <iostream>

int main()
{
  double d = 123.4567;

  std::cout<< std::fixed << d / 10 <<'\n';
}

sorry what i mean wasnt remainder. is the decimal point.
as in 5.7089 i wan it to show as 5 only.
i think i found the solution. using floor function?

>sorry what i mean wasnt remainder. is the decimal point.
>as in 5.7089 i wan it to show as 5 only.
Yes, that's a common mistake. :icon_rolleyes:

>i think i found the solution. using floor function?
That's one way, sure. Another is to cast to an integral type, in which case the precision is truncated (no rounding takes place). Yet another is the modf function, which comes in handy when you also need the precision, but not the two parts together:

#include <cmath>
#include <iostream>

int main()
{
  double d = 123.987;
  double i;
  double e;

  e = std::modf ( d, &i );

  std::cout<<"Splitting "<< d <<":\n";
  std::cout<< i <<'\n'<< e <<'\n';
}

>If you want to use modulo without floating points try (int)myFloat % (int)myOtherFloat
Brilliant, Holmes. Now show me how your idea works when myFloat is 0.5 and myOtherFloat is 0.3.

Comments
Good counter-example
This question has already been answered. Start a new discussion instead.