Thread: please help

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    1
    Rep Power
    0

    please help


    //There are approximately 3.156X10^7 seconds in a year. Write a program that request your age in years and then displays the equivalent number of seconds//
    // Example output for a person 1 year old: (notice three values are being output in the following line, not 2 as shown in the textbook)
    // Your age in years: 1, age in seconds: 31560000.000 or 3.156e+007.
    // your output must be formatted exactly like the example above, or like the following:
    // Your age in years: 1, age in seconds: 31560000.000 or 3.156e+07. //

    #include <stdio.h>

    void GetAge(void)
    void PrintAge(void)

    int main(void)
    {
    void GetAge();
    void PrintAge()
    return 0;
    }
    void GetAge()
    {
    int age;
    printf("what is your age ");
    scanf("%d", &age);
    printf("so you are %d years old",age);
    return 0;
    }
    void PrintAge (void)
    {
    printf("display you age in %d,%f,%e ");
    }

    please help me with syntax error . or the functions
  2. #2
  3. /(bb|[^b]{2})/

    Join Date
    Nov 2001
    Location
    Somewhere in the great unknown
    Posts
    5,163
    Rep Power
    792
    Three things:
    1) There are three lines missing a semi-colon from the end of it. Both of the function declarations at the beginning and the second function call in the main function block.
    2) Always show the error you are receiving so that it is easier to determine the problem.
    3) It is frowned upon to get help for homework. You should approach your teacher & peers first.
  4. #3
  5. not a fan of fascism (n00b)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Feb 2003
    Location
    ct
    Posts
    2,756
    Rep Power
    95
    in addition to what he said,

    void GetAge()
    {
    int age;
    printf("what is your age ");
    scanf("%d", &age);
    printf("so you are %d years old",age);
    return 0;
    }


    should not return a value as it is void but u return 0, i would also always initialize my variables to 0 or null.
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    8
    Rep Power
    0
    You really should ask your teacher and/or your fellow students. I have a copy of your program on my computer and here is how to fix everything. This is everything, and it will work if you do all of these things:

    1. Semicolons at the end of lines 3, 4, and 9
    2. In the GetAge() menthod, change it from 'void GetAge()' to 'int GetAge()'
    3. In the 'main()' function, get rid of the two 'voids' in front of where you call both of the functions.
    4. In the GetAge prototype, change the 'void' in front to be 'int'

    It runs. You get the red screen of death, but I assume that this isn't your entire program.
  8. #5
  9. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,592
    Rep Power
    4207
    Onslaught, you forgot to mention #4 - BAD SUBJECT NAME. lahai419, allow me to present you with http://forums.devshed.com/t28414/s.html
  10. #6
  11. /(bb|[^b]{2})/

    Join Date
    Nov 2001
    Location
    Somewhere in the great unknown
    Posts
    5,163
    Rep Power
    792
    Your right, that should have been #1 on the list. ;)

IMN logo majestic logo threadwatch logo seochat tools logo