Not runing property

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
 
R

red floyd

Latina said:
Hi, I hope some one can help me.

For some reason is not going to the function.
I dont have any errors.

What is your input? What were you expecting to happen? How do you know
it's not going to 'the function'?
 
R

Rolf Magnus

Latina said:
Hi, I hope some one can help me.

For some reason is not going to the function.
I dont have any errors.

What exactly happens? How do you know that the function isn't called?
Your code does work here.
 
L

Latina

What exactly happens? How do you know that the function isn't called?
Your code does work here.


After I enter the second year and I press enter,
the program terminates.
This is my output:

WELCOME to the Date Program

This program is going to determine the time that has passed between
two dates.
Please enter the dates.
It can be your birthday or todays date

Enter the first date
Day: 1
Month: 12
Year: 2000
Enter the second date
Day: 4
Month: 3
Year: 2004
 
L

Latina

Hi, I hope some one can help me.
For some reason is not going to the function.
I dont have any errors.
[/QUOTE]
What exactly happens? How do you know that the function isn't called?
Your code does work here.

After I enter the second year and I press enter,
the program terminates.
It suppose to print out the difference of the two years.
This is my output:

WELCOME to the Date Program

This program is going to determine the time that has passed between
two dates.
Please enter the dates.
It can be your birthday or todays date

Enter the first date
Day: 1
Month: 12
Year: 2000
Enter the second date
Day: 4
Month: 3
Year: 2004
 
J

Jim Langston

Latina said:
After I enter the second year and I press enter,
the program terminates.
This is my output:

WELCOME to the Date Program

This program is going to determine the time that has passed between
two dates.
Please enter the dates.
It can be your birthday or todays date

Enter the first date
Day: 1
Month: 12
Year: 2000
Enter the second date
Day: 4
Month: 3
Year: 2004

"Terminates". Are you running on Windows? And by terminates do you mean
the program text window closes? And are you running it by pressing F5?

Try running it with ctrl-F5, which will pause before it closes so you can
see the output. Or wait for something at the end before it closes. Such as
putting
std::string Wait;
std::cin >> Wait;
at the bottom of main.
 
L

Latina

"Terminates". Are you running on Windows? And by terminates do you mean
the program text window closes? And are you running it by pressing F5?

Try running it with ctrl-F5, which will pause before it closes so you can
see the output. Or wait for something at the end before it closes. Such as
putting
std::string Wait;
std::cin >> Wait;
at the bottom of main.- Hide quoted text -

- Show quoted text -

Thanks, I got it ^_^
 
L

Latina

"Terminates". Are you running on Windows? And by terminates do you mean
Thanks, I got it ^_^- Hide quoted text -

- Show quoted text -

But after is printing the total, the window doesnt close.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top