algorithm to read age years, months, and years and convert the value to age only in days

Asked

Viewed 62 times

0

#include <iostream>


using namespace std;

int main() {
 int idade;
 int anos;
 int meses;
 int dias;
  
cin >> anos >> meses >> dias;

 meses= anos*12;



 dias= meses*30;

 cout << ("sua idade em dias:");

 




 
 





                       
 
}

In case he’s showing up for me to enter the amount in days, but he should answer and not me.

1 answer

1


You have to accumulate and at the end print the amount of days.

#include <iostream>
using namespace std;
 
int main() {
    int anos, meses, dias;
    cin >> anos >> meses >> dias;
    cout << "Anos: " << anos << endl;
    cout << "Meses: " << meses << endl;
    cout << "Dias: " << dias << endl;
    meses += anos*12;
    dias += meses*30;
    cout << "Sua idade em dias: " << dias << endl;;
    return 0;
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.