Thread: two errors, help!

  1. #1
    Registered User
    Join Date
    Mar 2010
    Posts
    4

    two errors, help!

    Hey everyone!

    I'm new to programming (taking a class in C) and have two errors I don't know how to fix.
    The errors are:

    try1.c:17: error: conflicting types for calculateMonthlyPayment
    try1.c:12: error: previous implicit declaration of calculateMonthlyPayment was here

    I know they're related, but can't figure out how to correct them. Help?

    Program:

    Code:
    #include <stdio.h>
    #include <math.h>
    
    double calculateMontlyPayment (double amount, double rate, double years);
    void printInformation (double amount, double rate, double years, double calculate);
    
    int main ()
    {
    double rate, amount, years, calculate;
    printf ("Enter the loan amount, interest rate (as a percent), and number of years for the loan\n\n");
    scanf ("%lf%lf%lf", &amount, &rate, &years);
    calculate=calculateMonthlyPayment (amount, rate, years);
    printInformation (amount, rate, years, calculate);
    return 0;
    }
    
    double calculateMonthlyPayment (double amount, double rate, double years)
    {
    return ((rate*pow((1.0+rate), (years*12.0)))/(pow((1.0+rate), (years*12.0))-1.0)*amount);
    }
    
    void printInformation (double amount, double rate, double years, double calculate)
    {
    printf ("The amount of the loan:  %6.2lf\n", amount);
    printf ("Interest rate per year (user entered):   %6.2lf\n", rate);
    printf ("Interest rate per month:           \n");
    printf ("Number of years:   %6.2lf\n", years);
    printf ("Number of months:  %6.2lf\n", (years*12));
    printf ("Monthly payment:   %6.2lf\n", calculate);
    }

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    you are missing h in Montly in function prototype...
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    Registered User
    Join Date
    Mar 2010
    Posts
    4
    thank you No one else caught that, even the professor.

  4. #4
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    All those carrots as a kid, are paying off, Vart!

  5. #5
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Quote Originally Posted by Adak View Post
    All those carrots as a kid, are paying off, Vart!
    just paying attention to the compiler, as someone said - compiler programmers do not choose their messages out of the blue...
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  6. #6
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by vart View Post
    just paying attention to the compiler, as someone said - compiler programmers do not choose their messages out of the blue...
    That's just crazy talk!


    Quzah.
    Hope is the first step on the road to disappointment.

  7. #7
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Quote Originally Posted by quzah View Post
    That's just crazy talk!


    Quzah.
    you mean you just ignore everything your compiler tells you? I thought better of you...
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. global namespace errors
    By stubaan in forum C++ Programming
    Replies: 9
    Last Post: 04-02-2008, 03:11 PM
  2. Ten Errors
    By AverageSoftware in forum Contests Board
    Replies: 0
    Last Post: 07-20-2007, 10:50 AM
  3. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 05:44 PM
  4. Help me with these errors... :-(
    By major_small in forum C++ Programming
    Replies: 6
    Last Post: 09-07-2003, 08:18 PM
  5. errors in class(urgent)
    By ayesha in forum C++ Programming
    Replies: 2
    Last Post: 11-10-2001, 06:51 PM

Tags for this Thread