R-Ts NetWorks

Server the Best

How To Find Complete Age in Year, Month & Days


The Programme is built in C++ Language

The Programme is made without Graphics

You can run this in Dev C++ or Tubo C

The Code is given below 

————————————————–

#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
main()
{
int by,bm,bd,py,pm,pd,td,tm,ty;
int ppd,ppm,pppm,ppy;
int ch=1;
cout<<“nntttt Age Calculatornn”;
cout<<“ttttMade By : Waqar Hussainnn”;
cout<<“ttttCell No : +92 315 754 7702nn”;


while(ch==1)
{
cout<<“tEnter Birth Recordnn”;
cout<<“tYear For Example 1991 : “;
cin>>by;
cout<<“tMonth For Example 8 : “;
cin>>bm;
cout<<“tDate For Example 2 : “;
cin>>bd;
cout<<“nntEnter Current Recordnn”;
cout<<“tYear For Example 2012 : “;
cin>>py;
cout<<“tMonth For Example 7 : “;
cin>>pm;
cout<<“tDate For Example 4 : “;
cin>>pd;
// For Date
if(pd<bd)
{
ppd=pd+30;
td=ppd-bd;
}
else if(pd>bd)
td=pd-bd;
else if(pd==bd)
td=pd-bd;

// For Month
if(pd<bd)
{
ppm=pm-1;
if(ppm<bm)
{
pppm=ppm+12;
tm=pppm-bm;
}
else if(ppm>bm)
{
tm=ppm-bm;
}
else if(ppm==bm)
{
tm=ppm-bm;
}
}
else if(pd>bd)
{
if(pm<bm)
{
ppm=pm+12;
tm=ppm-bm;
}
else if(pm>bm)
{
tm=pm-bm;
}
else if(pm==bm)
{
tm=pm-bm;
}
}
else if(pd==bd)
{
if(pm<bm)
{
ppm=pm+12;
tm=ppm-bm;
}
else if(pm>bm)
{
tm=pm-bm;
}
else if(pm==bm)
{
tm=pm-bm;
}
}
//// For Year
if(pm<bm||ppm<bm||pppm<bm)
{
ppy=py-1;
ty=ppy-by;
}
else if(ppm>bm||pppm>bm||pm>bm)
{
ty=py-by;
cout<<endl;
}
else if(ppm>bm&&pppm>bm&&pm>bm&&pd>bd)
{
ty=py-by;
cout<<endl;
}
else if(ppm==bm||pppm==bm||pm==bm||bd==td)
{
ty=py-by;
cout<<endl;
}
cout<<“nnttt … Complete Age Till Today ….nn”;
cout<<endl;
cout<<“tt————————————————-n”;
cout<<“tt|t”<<“Year”<<setw(7)<<“|”<<setw(9)<<“Month”<<setw(4)<<“|”<<setw(7)<<“tDay”<<“t|”<<endl;
cout<<“tt————————————————-n”;
cout<<“tt|t”<<ty<<setw(9)<<“|”<<setw(5)<<tm<<setw(8)<<“|”<<setw(7)<<“t”<<td<<“t|”<<endl;
cout<<“tt————————————————-n”;
cout<<endl<<endl;
cout<<“1 : To Continue”;
cout<<endl;
cout<<“2 : To Exit”;
cout<<“nnEnter Your Choice < 1/2 > : “;
cin>>ch;
cout<<endl<<endl;
}
getch();
}

                                   //////////////////////

                                  //////  The End   //////

                                  //////////////////////

Advertisements

July 14, 2012 - Posted by | C/C++ Tutorial, Education

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: