First time programmer need a little help

This is a discussion on First time programmer need a little help within the C Programming forums, part of the General Programming Boards category; So I am pretty new to programming as I am a freshman in college. I have written out my program ...

  1. #1
    Registered User
    Join Date
    Feb 2009
    Posts
    1

    First time programmer need a little help

    So I am pretty new to programming as I am a freshman in college. I have written out my program for the assignment this week and I just can't for the life of me figure out how to get rid of theses errors.

    Code:
    #include <stdio.h>
    
    void greet_user(void);
    double get_initial_cost(void);
    double get_fuel(void);
    double get_tax(void);
    double calculate_cost(double initial, double fuel, double tax)
    void give_results(double calculate)
    
    int main (void)
    {
      greet_user();
      get_initial_cost();
      get_fuel();
      get_tax();
      calculate_cost();
      give_results();
      return (0);
    }
    
    
    void greet_user(void)
    {
      printf("This program will calculate the cost of your house after");
      printf(" owning it for 5 years.");
      return;
    }
    
    double get_initial_cost(void)
    {
      double initial;
      printf("Please enter in the initial cost of your house:/n");
      scanf("%lf", &initial);
      return(initial);
    }
    
    double get_fuel(void)
    {
      double fuel;
      printf("Please enter in your annual fuel cost:/n");
      scanf("%lf", &fuel);
      return(fuel);
    }
    
    double get_tax(void)
    {
      double tax;
      printf("Please enter in your tax rate:/n");
      scanf("%lf", &tax);
      return(tax);
    }
    
    double calculate_cost(double initial, double fuel, double tax)
    {
      double cost;
      cost = (initial + fuel + tax) * 5.0;
      return(cost);
    }
    
    void give_results(double cost)
    {
      printf("The total cost of your house after owning it for");
      printf(" five years is %f",cost);
      return;
    }
    I get these errors:

    In function 'calculate_cost':
    10: error: parse error before "int"
    13: error: old-style parameter declarations in prototyped function definition
    at top level:
    54: error: redefinition of 'calculate_cost'
    13: error: previous definition of 'calculate_cost' was here

    I know these are some dumb errors, but I have been trying to get rid of them for the past couple of hours and nothing seems to work.

    Any help is greatly appreciated!

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Did you try adding ; to the end of lines 7 and 8? The other errors you are having probably cascade from this.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 26
    Last Post: 07-05-2010, 10:43 AM
  2. Help with assignment!
    By RVDFan85 in forum C++ Programming
    Replies: 12
    Last Post: 12-02-2006, 11:46 PM
  3. Is this really true or it's just science fiction?
    By Nutshell in forum A Brief History of Cprogramming.com
    Replies: 145
    Last Post: 04-09-2002, 06:17 PM
  4. time class
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 12-11-2001, 09:12 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21