Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

#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;
      |       ^~

>Solution :

You have declared your variable at

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading