two errors, help!

This is a discussion on two errors, help! within the C Programming forums, part of the General Programming Boards category; Hey everyone! I'm new to programming (taking a class in C) and have two errors I don't know how to ...

  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
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    you are missing h in Montly in function prototype...
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  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
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    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...
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  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
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    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...
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

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, 04:11 PM
  2. Ten Errors
    By AverageSoftware in forum Contests Board
    Replies: 0
    Last Post: 07-20-2007, 11: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, 09: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


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