77 902
Assignments Done
Successfully Done
In August 2019

Answer to Question #15862 in C++ for Tahreem virk

Question #15862
Input Name and Date of Birth from the user and display name with age. The age should be displayed as number of years.
Expert's answer

char name[30];
int& y, m, d;
double T, a, b;

void main(){
cout<<"Enter the name: ";
cout<<"Enter the year of birth (1970-2012): ";
cout<<"Enter the month of birth (1-12): ";
cout<<"Enter the day of birth (0-31): ";
T = time(NULL);
a = d;
for (int i=1; i<m; i++){
& a += 30;
& if (i%2!=0) a += 1;
for (i=1970; i<y; i++){
& a += 365;
& if (i%4==0) a += 1;
a = a*24*3600;
int b=0;
while (a<=T){
& a += 365*24*3600;
& if (y%4==0) a+= 24*3600;
& if (a<=T) b++;
& y++;
cout<<"The age of "<<name<<" is "<<b<<" years.\n";

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!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions