Thread: functions....please help

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    11

    Unhappy functions....please help

    I am trying to write a program that:
    write a function called convert that accepts 4 arguments as follows:
    1) integer seconds
    2) reference int hours
    3) reference int minutes
    4) reference int remain_sec

    Convert within your function the value of the integer "seconds" into hours, minutes, and remaining seconds. Assign these values to your reference variables within the "convert" function. Return to the main() function and print the corresponding arguments as referenced by the convert() function. Do not use global variables.......

    ... This is what I have so far....

    #include<iostream.h>

    void(convert(int, int&, int&, int&, int&, &int&);

    int main()
    {
    int seconds, hours, minutes, remain_sec;
    cout<<"Please enter seconds:";
    cin>>seconds;

    int seconds;
    cout<<"Enter seconds";
    cin>> seconds;

    hours()
    hours = seconds/360;

    minutes()
    minutes = hours/60;

    remain_sec()
    remain_sec = minutes/60;

    }


    Any suggestions or help would be appreciated...

    [email protected]

  2. #2
    Flash Animator, OF DOOOOM bluehead's Avatar
    Join Date
    Nov 2001
    Posts
    269
    Heh i dunno what your trying to say, be alittle clear, but will this help:


    #include <iostream.h>

    int minutes;
    int hours;
    int seconds;

    void convert()
    {
    minutes = seconds * 60;
    hours = minutes * 60;
    }

    int main()
    {
    cout<<"Please enter seconds:";
    cin>>seconds;

    convert();

    cout<<hours<<":"<<minutes<<":"<<seconds;
    return 0;
    }

    hehe....If this helps your welcome
    Code:
    #if _emo
      #define stereo_type_i_dislike
    #endif

  3. #3
    Flash Animator, OF DOOOOM bluehead's Avatar
    Join Date
    Nov 2001
    Posts
    269
    heh i just compiled it, and figured out thats its not write: instead of puttin (*) put a (/) and change the hour and minutes to float numbers (use float instead of int)
    Code:
    #if _emo
      #define stereo_type_i_dislike
    #endif

  4. #4
    Registered User
    Join Date
    Aug 2001
    Posts
    52
    declare void convert( int, int *, int *, int * );

    declare main ()

    declare integer variables seconds, hours, minutes, secsRemain;

    Prompt for user input;
    Get user input;

    Pass input to convert( seconds, &hours, &minutes, &secsRemain );

    Print format hours:minutes:secsRemain;

    end main


    void convert( int sec, int *hr, int *min, int *secRem )

    declare integer temp;

    hr = sec / numSecsInHour;
    temp = sec mod numSecsInHour;
    min = temp / numSecsInMin;
    secRem = temp mod numSecsInMin;

    end convert

    hth,

  5. #5
    Flash Animator, OF DOOOOM bluehead's Avatar
    Join Date
    Nov 2001
    Posts
    269
    lol i feel like i dont know anything, im not the right person for this (lol) heh wait for someone else 2 reply
    Code:
    #if _emo
      #define stereo_type_i_dislike
    #endif

  6. #6
    Registered User rmullen3's Avatar
    Join Date
    Nov 2001
    Posts
    330
    Code:
    template <typename styp, typename typ>
    void convert (styp seconds, typ &h, typ &m)
    {
          m = seconds / 60;
          h = m / 60;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Void Functions Help
    By bethanne41 in forum C++ Programming
    Replies: 1
    Last Post: 05-09-2005, 05:30 PM
  2. Functions and Classes - What did I do wrong?
    By redmage in forum C++ Programming
    Replies: 5
    Last Post: 04-11-2005, 11:50 AM
  3. calling functions within functions
    By edd1986 in forum C Programming
    Replies: 3
    Last Post: 03-29-2005, 03:35 AM
  4. Factory Functions HOWTO
    By GuardianDevil in forum Windows Programming
    Replies: 1
    Last Post: 05-01-2004, 01:41 PM
  5. Shell functions on Win XP
    By geek@02 in forum Windows Programming
    Replies: 6
    Last Post: 04-19-2004, 05:39 AM