TOPIC

Answer error 5%

David T. Ramírez asked 11 months ago

Please!! I need help, I don't get find the error...

#include <iostream>

int main (){

int total {} ; // en dias
std::cin >> total ;
int year {}, month {}, day {};

year = total / 365 ;
month = (total / 30)%12 ;
day = (total % 365)%30 ;

std::cout<<year<<" ano(s)\n";
std::cout<<month<<" mes(es)\n";
std::cout<<day<<" dia(s)\n"; 

return 0;

}

Remember not post solutions. Your post may be reviewed by our moderators.

  • CSE_19_Masrafi Bin Seraj replied 11 months ago

    You have a bug on the 10th line calculating month.

    change this line:

    month = (total / 30)%12 ;

    To:

    month = (total % 365 )/30 ;