Age Calculator Program Code in C++

This Program will calculate age in days months and in years. The program ask for current date month and year and after this his date of birth's (in number) ,date of birth month's month and the year of birth.

Source Code

#include<iostream>
using namespace std;
int days  (int a, int b);
int months (int a, int b);
int years  (int a, int b);
int main ()
{
 int current_date ;
 int current_month;
 int current_year;
 int dob;
 int dob_month;
 int dob_year;
 int date;
 int month;
 int year;
 cout<<" \t \t \t LEP AGE CALCULATOR \n \n  ";
 cout<<" Enter Current Date : ";
 cin>>current_date;
 cout<<endl;
 cout<<"   Enter Current Month : ";
 cin>>current_month;
 cout<<endl;
 cout<<"   Enter Current Year : ";
 cin>>current_year;
 cout<<endl;
 cout<<"   Enter Your Date of Birth 's Day : ";
 cin>>dob;
 cout<<endl;
 cout<<"   Enter Your Date of Birth' Month : ";
 cin>>dob_month;
 cout<<endl;
 cout<<"   Enter Your Date of Birth ' Year : ";
 cin>>dob_year;
 date = days(current_date,dob);
 month = months(current_month,dob_month);
 year = years(current_year,dob_year);
 cout<<endl<<endl;
 cout<<" \t \t You Age is : "<<date<<" Days  " <<month<<" Months "<<" and "<<year<<" Years old "<<endl<<endl;
 cout<<" \t \t \t\ \t \t \t Keep Grwoing :)";
}
int days  (int a , int b)
{
 return a-b;
}
int months  (int a , int b)
{
 return a-b;
}
int years  (int a , int b)
{
 return a-b;
}

Output of the Program

Age Calculator in C++

Share on Google Plus

About Asad

Asad Niazi is Software Engineer , Programmer, Web Developer and a young mentor of BloggersTown and PProgramming. Asad Love to writes about Technology, Programming, Blogging and make money online.

2 comments:

  1. in the return function...

    write
    return abs(a-b);

    because without using abs its showing negative values of days and months in some cases.

    ReplyDelete
  2. please correct your spelling of growing
    you spelled grwoing
    rest of program is top notch

    ReplyDelete