-
Language
C++
-
Description
Age calculation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#ifdef __MSDOS__
#include <iostream.h>
#include <stdlib.h>
#else
#include <iostream>
#include <cstdlib>
using namespace std;
#endif
int main (void)
{
int age, birth_day, birth_month, birth_year, current_day;
int current_month, current_year;
cout << "Enter the value of birth day: ";
cin >> birth_day;
cin.get();
cout << "Enter the value of birth month: ";
cin >> birth_month;
cin.get();
cout << "Enter the value of birth year: ";
cin >> birth_year;
cin.get();
cout << "Enter the value of current day: ";
cin >> current_day;
cin.get();
cout << "Enter the value of current month: ";
cin >> current_month;
cin.get();
cout << "Enter the value of current year: ";
cin >> current_year;
cin.get();
age=current_year-birth_year;
if(birth_month>current_month||(birth_month==current_month&&birth_day>current_day))
age=age-1;
cout << "Value of age: " << age << endl;
cout << endl;
system ("pause");
return EXIT_SUCCESS;
}
#include <iostream.h>
#include <stdlib.h>
#else
#include <iostream>
#include <cstdlib>
using namespace std;
#endif
int main (void)
{
int age, birth_day, birth_month, birth_year, current_day;
int current_month, current_year;
cout << "Enter the value of birth day: ";
cin >> birth_day;
cin.get();
cout << "Enter the value of birth month: ";
cin >> birth_month;
cin.get();
cout << "Enter the value of birth year: ";
cin >> birth_year;
cin.get();
cout << "Enter the value of current day: ";
cin >> current_day;
cin.get();
cout << "Enter the value of current month: ";
cin >> current_month;
cin.get();
cout << "Enter the value of current year: ";
cin >> current_year;
cin.get();
age=current_year-birth_year;
if(birth_month>current_month||(birth_month==current_month&&birth_day>current_day))
age=age-1;
cout << "Value of age: " << age << endl;
cout << endl;
system ("pause");
return EXIT_SUCCESS;
}