Not runing property

Discussion in 'C++' started by Latina, Nov 8, 2007.

  1. Latina

    Latina Guest

    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
     
    Latina, Nov 8, 2007
    #1
    1. Advertising

  2. Latina

    red floyd Guest

    Latina wrote:
    > 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'?

    > 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
    >
     
    red floyd, Nov 8, 2007
    #2
    1. Advertising

  3. Latina

    Rolf Magnus Guest

    Latina wrote:

    > 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.
     
    Rolf Magnus, Nov 8, 2007
    #3
  4. Latina

    Latina Guest

    On Nov 7, 11:14 pm, Rolf Magnus <> wrote:
    > Latina wrote:
    > > 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.



    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
     
    Latina, Nov 8, 2007
    #4
  5. Latina

    Latina Guest

    On Nov 7, 11:22 pm, Latina <> wrote:
    On Nov 7, 11:14 pm, Rolf Magnus <> wrote:

    > Latina wrote:
    > > 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.


    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
     
    Latina, Nov 8, 2007
    #5
  6. Latina

    Jim Langston Guest

    "Latina" <> wrote in message
    news:...
    > On Nov 7, 11:14 pm, Rolf Magnus <> wrote:
    >> Latina wrote:
    >> > 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.

    >
    >
    > 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.
     
    Jim Langston, Nov 8, 2007
    #6
  7. Latina

    Latina Guest

    On Nov 7, 11:28 pm, "Jim Langston" <> wrote:
    > "Latina" <> wrote in message
    >
    > news:...
    >
    >
    >
    >
    >
    > > On Nov 7, 11:14 pm, Rolf Magnus <> wrote:
    > >> Latina wrote:
    > >> > 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.

    >
    > > 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.- Hide quoted text -
    >
    > - Show quoted text -


    Thanks, I got it ^_^
     
    Latina, Nov 8, 2007
    #7
  8. Latina

    Latina Guest

    > > "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 ^_^- Hide quoted text -
    >
    > - Show quoted text -


    But after is printing the total, the window doesnt close.
     
    Latina, Nov 8, 2007
    #8
  9. Latina

    Jim Langston Guest

    "Latina" <> wrote in message
    news:...
    >> > "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 ^_^- Hide quoted text -
    >>
    >> - Show quoted text -

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


    Press enter.
     
    Jim Langston, Nov 8, 2007
    #9
  10. Latina

    Latina Guest

    > > But after is printing the total, the window doesnt close.
    >
    > Press enter.


    Still, only when I enter something closes.
     
    Latina, Nov 8, 2007
    #10
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nikolay Petrov

    Runing Client-side code

    Nikolay Petrov, Mar 22, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    620
    Jason Mauss
    Mar 24, 2005
  2. Replies:
    1
    Views:
    513
    Larry
    Mar 7, 2006
  3. Thomas
    Replies:
    2
    Views:
    1,920
    Peter van Merkerk
    Sep 2, 2003
  4. Peng Yu
    Replies:
    7
    Views:
    378
    Anoop Aryal
    Mar 29, 2005
  5. John Morrill

    JQuery and javascript not runing in the head tag

    John Morrill, Jun 28, 2010, in forum: ASP General
    Replies:
    3
    Views:
    1,190
    Dooza
    Jun 29, 2010
Loading...

Share This Page