Thread: Help with a couple compiler errors

  1. #1
    Registered User
    Join Date
    Mar 2005

    Help with a couple compiler errors

    I'm kind of new to the C language and I had to write a program that computes a monthly payment. I'm using the gcc compiler and when I run the compile, I get the following messages:

    loan.c: In function "int main":
    loan.c:34: error: too few arguments to function 'pow'

    Any ideas? Here is my code:

             Filename: loan.c
             Description: The monthly payment for an installment loan.
    #include <stdio.h>
    #include <math.h>
     int main()
          /* memory allocation for data */
          double monthlypayment;
          double principal;
          double rate;
          int months;
          /* prompt user for data */
      printf ("Enter the principal amount of the loan:");
      scanf  ("%lf",& principal);
      printf ("Enter the yearly interest rate (eg.0.05):");
      scanf  ("%lf",& rate);
      printf ("Enter the total number of payments in months:");
      scanf  ("%d",& months);
           /* compute monthly payment */
           monthlypayment = principal*(rate/12)/1-pow(1+rate/12)-months;
           /* display result */
      printf ("Your monthly payment will be: $%lf/n",monthlypayment);
           /* End */
     return 0;

  2. #2
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Sydney, Australia
    What are you trying to do?

    pow takes two arguments, for example pow(2,3) will compute 2 raised to the power of 3. You are only giving one argument.


    Also, remember that if you divide by an integer value, the result will be an integer. You probably want rate/12.0
    Last edited by cwr; 09-15-2005 at 09:21 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 05:44 PM
  2. compiler errors
    By Draco in forum C++ Programming
    Replies: 3
    Last Post: 10-25-2003, 11:08 AM
  3. compiler errors: win2k
    By crepincdotcom in forum C Programming
    Replies: 2
    Last Post: 10-07-2003, 02:16 PM
  4. Replies: 5
    Last Post: 11-13-2001, 04:38 PM
  5. Compiler errors
    By BellosX in forum C Programming
    Replies: 2
    Last Post: 09-21-2001, 03:24 AM