Home > Software engineering >  I don't understand the problem that the error want to tell me. i copied the error message
I don't understand the problem that the error want to tell me. i copied the error message

Time:09-28

#include <iostream>; 

using namespace std; 

int main() 

{ 

    int  total_of_seconds; 

cout << "please inter the total of seconds \n"; 

cin >> total_of_seconds ;

int seconds_per_day = 24* 60 *60 ;

int seconds_per_hours = 60 * 60 ;

int seconds_per_minutes= 60 ;

int number_of_days = floor (total_of_seconds/seconds_per_day) ;

int s = total_of_seconds % seconds_per_day ;

int number_of_hours=  floor (s/seconds_per_hours ) ;

int s %= seconds_per_hours;

int number_of_minutes= floor (s/seconds_per_minutes) ;

int s %= seconds_per_minutes;

int number_of_seconds = s;

cout << number_of_days <<":" << number_of_hours <<":" << number_of_minutes<< ":" << number_of_seconds<<endl ;

return 0;

}
/tmp/uGTkaIpa1f.cpp:11:22: error: 'floor' was not declared in this scope
   11 | int number_of_days = floor (total_of_seconds/seconds_per_day) ;
      |                      ^~~~~
/tmp/uGTkaIpa1f.cpp:14:7: error: expected initializer before '%=' token
   14 | int s %= seconds_per_hours;
      |       ^~

CodePudding user response:

You have declared your variable at

int s = total_of_seconds % seconds_per_day ;

and you're trying to re-declare it at

int s %= seconds_per_hours;

remove the int declaration

P.S. include the cmath for using floor

  • Related