Q BgQuestion:

      
Pupil
Karma Points: 56
Respect (77%):
posted by  lovely H-A on 11/7/2009 4:06:16 AM  |  status: Closed  |  Earned Karma: 56

please help me with this problem ...

Course Textbook Chapter Problem Needs by
N/A N/A N/A N/A 11/9/2009 at 1:00:00 PM
Question Details:

Write a C++ programme that asks the user to enter his age in days. Calculate then his age in:

Years – Months – Days

1 year = 365 days

1 year = 12 months

1 month = 30 days

AAnswers:

Answer Question Ask for clarification
Pupil
Karma Points: 56
posted by lovely H-A on 11/7/2009 4:22:36 AM  |  status: Live
Asker's Rating: N/A-Posted by Person Asking Question   
Response Details:

#include <iostream>

using namespace std;

void main()

{

int Days, Months, Years, R, Age;

cout << "Give the Age in days = " ;

cin >> Age; // 3725, 8734, 76453

Years = Age / 365; //

R = Age % 365; //

Months = R / 30; //

Days = R % 30; //

cout << "Your Age = " << endl;

cout << Years << ':' << Months

<< ':' << Days << endl;

}

this is my answer but I couldn't check whether it's right or wrong becuase I don't have the C++ programme , so is it right ? if so I will rate you as a lifesaver :)
thanks
Oracle
Karma Points: 31,880
posted by rapunzel on 11/7/2009 10:46:38 AM  |  status: Live
Asker's Rating: Helpful   
Response Details:
please rate - thanks

given the constraints of number of days in month, your program is correct.  of course 360 days which is less then 12 months, gives you 12 months

download Dev C++ from this site.  Free, very easy to use and then you can test your code

http://bloodshed.net/dev/devcpp.html




Note to all members 1. Please 1 question per post 2. Show respect to your fellow members by rating all answers. 3. When rating remember that the first answer is not necessarily the best answer. 4. When answering questions, explain what you are doing, so that the asker will learn, don't just give a meaningless number. 5. Your answers should be your work. Don't copy from another member, this is Karma abuse and possible disciplinary actions against you. and GOOD LUCK to you all!!
Mentor
Karma Points: 543
posted by Abdul Rafay on 11/7/2009 11:45:15 AM  |  status: Live
Asker's Rating: Lifesaver   
Response Details:
#include<iostream.h>
void main()
{
int age;
int day=0;
int month=0;
int year=0;
int rem=0;

cout<<"Enter Age in Days= ";
cin>>age;
if(age>365)
{
year=(age)/365;
rem=age%365;
if(rem>30)
{
month=rem/30;
day=rem%30;
}
else
{
day=rem%30;
}
}
else
{
if(age>30)
{
month=(age)/30;
day=age%30;
}
else
{
day=age;
}
}
cout<<"Your Age in Calender"<<endl;
cout<<"Years= "<<year<<" Month= "<<month<<" Days= "<<day<<endl;
}


Abdul Rafay
Answer Question Ask for clarificarion

Join Cramster's Community

Cramster.com brings together students, educators and subject enthusiasts in an online study community. With around-the-clock expert help and a community of over 100,000 knowledgeable members, you can find the help you need, whenever you need it. Join for free today » How Cramster is different from tutoring »