+ 6
Hi guys, please help me for creating a c++ code , which output is age & input is date of birth
7 Respuestas
+ 8
I wants in c++ code
+ 7
in c++ lang,
+ 2
In what language? And what have you tried?
+ 2
Here's one possible algorithm:
- ask user to input date of birth
- extract year of birth from the date
- obtain current year
- subtract year of birth from current year to obtain the age
- compare current month / day of month to that of birth date
- if current month / day is earlier, reduce age by 1
- output age
+ 1
Try to implement the algorithm I outlined. If you get stuck, show your code and describe what doesn't work.
+ 1
#include <iostream>
using name space std;
int main ()
{
int birthyear;
int currentyear;
int age=0;
cout<< "enter you birth year :"<<endl;
cin>> birthyear;
cout << "enter the current year:"<<endl;
cin>>currentyear;
age=currentyear-birthyear;
cout<< "your age is :"<<age<<endl;
return 0
/* this prograrm made by mahmood hurmuzlu */
}
+ 1
@mahmood: the question asks to enter date of birth not year of birth.