Answer to Question #4508 in C++ for Azi Amar

Question #4508
Simple Question:
how would I write a C++ program that converts an age in years to the age in days?
I seem to be getting an error and I'm not sure what the errorf is or how to solve it.
1
Expert's answer
2011-10-11T08:47:55-0400
#include <iostream>

using namespace std;

void
main(void){
int age = 0;
int dayOffset = 0;
int days =
0;
cout << "Please, enter an age: ";
cin >>
age;

dayOffset = (int)age / 4;
days = age * 365 +
dayOffset;

cout << "Age in days: " << days <<
endl;
cout << "\nInput 0 and press Enter exit...";
cin
>> dayOffset;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS