Thread: no problem here, just some bordom

  1. #1
    Registered User
    Join Date
    Jul 2004
    Posts
    5

    no problem here, just some bordom

    hey guys i was bored but yeah i made this program cause i dont have much skill and i wanted something to do.

    Code:
    #include <iostream>
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    
    using namespace std;
    
    int main()
    {
    int months, weeks, days, age;
    
    cout<<"hey how old are you?\n";
    cin>>age;
    months = age*12;
    weeks = age*52;
    days = age*365;
    cout<<"You are "<<months<<" months old, or "<<weeks<<" weeks old, or "<<days<<" days old! wow\n";
        system("pause");
        return 0;
    }

  2. #2
    Registered User
    Join Date
    Jul 2004
    Posts
    98
    I make some change like this:

    Code:
    #include <iostream>
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    
    using namespace std;
    //defined const 
    const int MonthsOfoneYear = 12;
    const int WeeksOfoneYear  = 52;
    const int DaysOfoneYear     = 365;
    
    int main()
    {
    int months, weeks, days, age;
    
    cout<<"hey how old are you?\n"<<endl;      //add endl;
    cout<<"Please enter your age: "<<flush;     //or add endl;
    cin>>age;
    cout<<endl;                                                  //change line
    cout<<"You are "<<age<<" years old!"<<endl;
    
    months = MonthsOfoneYear * age ;
    weeks  = WeeksOfoneYear *  age ;
    days     = DaysOfoneYear  *    age ;
    
    cout<<"You are "<<months<<" months old, "<<endl;
    cout<<" or "<<weeks<<" weeks old, "<<endl;
    cout<<" or "<<days<<" days old! wow\n"<<endl;
    
        system("pause");       // I often use getchar() to pause display window.
        return 0;
    }

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    What about leap years?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    don't forget that there needs to be a February 30th every 4000 years

  5. #5
    Registered User
    Join Date
    Jul 2004
    Posts
    5
    what year does leap year fall on so i can check that in an if statement

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > what year does leap year fall on so i can check that in an if statement
    Leap years happen more frequently than some people use a search engine to find out the answers to such basic questions.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  7. #7
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    Here's the leap year charts from NCAR's web site.

    http://www.ihateaol.co.uk/misc/galle...ics/google.gif

    (sorry jrahhali)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 04:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM