-2
float SecondsPerDay = 24 * 60 * 60;
float SecondsPerHour = 60 * 60;
float SecondsPerMinute = 60;;
double NumberOfDays = floor(TotalSeconds / SecondsPerDay);
double Remainder  = (TotalSeconds%SecondsPerDay); // line with error
double NumberOfHour = floor (TotalSeconds / SecondsPerHour);
float Remainder = (TotalSeconds % SecondsPerHour);
double NummberOfMinute = floor (TotalSeconds / SecondsPerMinute);
    float Remainder = (TotalSeconds % SecondsPerMinute);
float NumberOfSeconds = Remainder;

the copmiler give me error when i write modulo operation im trying to delete % but its not working

Yksisarvinen
  • 18,008
  • 2
  • 24
  • 52
  • 3
    `operator%` only works on integral numbers like `int`/`long`... and not floating point numbers – Joel Sep 01 '23 at 10:05
  • Stack Overflow usage tip: Formatting doesn't work in code blocks, but you can easily mark some line with a comment. – Yksisarvinen Sep 01 '23 at 10:05
  • it works thanks for helping :) .... – Diyaa Masri Sep 01 '23 at 10:09
  • Why use floating point types for days, hours, minutes, seconds? It's not as if you ever said something like 1.23 days or 1+e5 hours. Use integral types when they should be used. – Friedrich Sep 01 '23 at 10:13
  • 2
    note this can be simplified using `std::chrono` to https://godbolt.org/z/5oc6W1o1z or even simpler https://godbolt.org/z/75KxcT8h6 – Alan Birtles Sep 01 '23 at 10:44

0 Answers0