Thread: using function

  1. #1
    Registered User
    Join Date
    Jan 2003
    Posts
    1

    using function

    The main function of your program will contain calls to the following functions:

    1st function (this function will return an integer):

    Main will call this function to prompt the user to input the ,this function will scan for the value and return it to main.

    2nd function (this function will have one argument):

    Main will call this function and pass the integer previously entered. This function will generate output described in exercise You must also output the value of the integer passed to the function.

    Example output for a person 1 year old: (notice three values are being output in the following line,

    Your age in years: 1, age in seconds: 31560000.000 or 3.156e+07.



    #include <stdio.h>

    #define AGE_IN_SECOND 31560000

    int main(void)
    {
    double SECOND,
    YEAR;
    printf("Enter YOUR AGE IN YEAR> ");
    scanf("%lf", &YEAR);

    SECOND = AGE_IN_SECOND * YEAR;
    printf("That equals %f SECONDS.\n", SECOND);

    return (0);
    }

    I AM HAVING PROBLEM DESIGNING OR WRITING THE FUNCTIONS TO CALL..
    WORKING PROBLEM FOR NOW
    Last edited by lahai419; 01-29-2003 at 10:57 AM.

  2. #2

  3. #3
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    That's nice What is it? [/sarcasm]
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  4. #4
    and the Hat of Clumsiness GanglyLamb's Avatar
    Join Date
    Oct 2002
    Location
    between photons and phonons
    Posts
    1,110
    LMFAO
    most of the time ppl who want other ppl to do their homework give it a nice package and tell some story why it wouldnt work etc.
    never seen just a whole page out a book.

    [note to myself]
    if i ever have to do some programming homework tell a little story round it. this way i will convince ppl that i actually tried to work it out+ dont forget to write some dumb code
    [/note to myself]

  5. #5
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    You're asking for homework, dint use code tags and you dont
    have tabs in your code.

    Baaaad.

  6. #6
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    OK, here's an example of how a main might look. See what you can do with it.
    Code:
    int main(void)
    {
      int Year;
    
      Year = GetYear();
      PrintAge(Year);
      
      return 0;
    }
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  3. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  4. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  5. const at the end of a sub routine?
    By Kleid-0 in forum C++ Programming
    Replies: 14
    Last Post: 10-23-2005, 06:44 PM