L
Latina
Hi, I hope some one can help me.
For some reason is not going to the function.
I dont have any errors.
Here is my code:
#include <iomanip>
#include <iostream>
using namespace std;
int calYrs(int, int);
int main()
{
int day1, day2;
int month1, month2;
int year1, year2;
int years;
cout<<" WELCOME to the Date Program\n\n";
cout<<"This program is going to determine the time that has
passed ";
cout<<"between two dates.\n";
cout<<"Please enter the dates.\nIt can be your birthday or
todays date\n";
cout<<"\nEnter the first date\nDay: ";
cin>>day1;
cout<<"Month: ";
cin>>month1;
if(month1>12||month1<=0)
{
cout<<"The month must be between 1 and 12\nPlease re-enter
month\n";
cin>>month1;
}
cout<<"Year: ";
cin>>year1;
cout<<"Enter the second date\nDay: ";
cin>>day2;
cout<<"Month: ";
cin>>month2;
if(month2>12||month2<=0)
{
cout<<"The month must be between 1 and 12\nPlease re-enter
month\n";
cin>>month2;
}
cout<<"Year: ";
cin>>year2;
years = calYrs(year1, year2);
cout<<"Total: "<<years;
return 0;
}
int calYrs(int y1, int y2)
{
int years;
if(y1>y2)
{
years=y1-y2;
}
else
{
years=y2-y1;
}
return years;
}
Thanks
For some reason is not going to the function.
I dont have any errors.
Here is my code:
#include <iomanip>
#include <iostream>
using namespace std;
int calYrs(int, int);
int main()
{
int day1, day2;
int month1, month2;
int year1, year2;
int years;
cout<<" WELCOME to the Date Program\n\n";
cout<<"This program is going to determine the time that has
passed ";
cout<<"between two dates.\n";
cout<<"Please enter the dates.\nIt can be your birthday or
todays date\n";
cout<<"\nEnter the first date\nDay: ";
cin>>day1;
cout<<"Month: ";
cin>>month1;
if(month1>12||month1<=0)
{
cout<<"The month must be between 1 and 12\nPlease re-enter
month\n";
cin>>month1;
}
cout<<"Year: ";
cin>>year1;
cout<<"Enter the second date\nDay: ";
cin>>day2;
cout<<"Month: ";
cin>>month2;
if(month2>12||month2<=0)
{
cout<<"The month must be between 1 and 12\nPlease re-enter
month\n";
cin>>month2;
}
cout<<"Year: ";
cin>>year2;
years = calYrs(year1, year2);
cout<<"Total: "<<years;
return 0;
}
int calYrs(int y1, int y2)
{
int years;
if(y1>y2)
{
years=y1-y2;
}
else
{
years=y2-y1;
}
return years;
}
Thanks