# Thread: don't have any clue how to do this

1. ## don't have any clue how to do this

i need to make a program that asks for the amount of a loan, the interest rate, and the length of the loan using scanf. then i need it to tell me what the monthly payment is.

i want to use "a" as the amount of the loan, the monthly interest rate is r and n is the length of the loan in months. P is the monthly payment.

my equation should be this p=a(r((1+r)^n))/((1+r)^n)-1))

I really don't know what i'm doing... if someone could show me how to do the exponents is the main part. thanks.

2. Originally Posted by newcstudent
my equation should be this p=a(r((1+r)^n))/((1+r)^n)-1))
Are you sure theres no way to simplify the equation?

3. i have no idea. i think it is simplified... it's much easier to visualize as a fraction... the whole first part is over the second part.

4. Originally Posted by newcstudent
if someone could show me how to do the exponents is the main part.
man pow

5. can you give me a short program using man pow? i've never seen it before... all i know how to use is printf, scanf and fputs.

6. Originally Posted by Dave_Sinkula
Ill save you some time, pow(x, y) , computes x to the power of y

Example: p=a(r((1+r)^n))/((1+r)^n)-1))

pow((1+r), n);

7. so i would define x as (1+r) and then use y instead of n?

8. is it man pow((1+r), n)
or is it pow((1+r), n)
and i put that at the beggining of my function right? next to my curly brace?

9. Originally Posted by newcstudent
so i would define x as (1+r) and then use y instead of n?
No, you could do exactly what i showed you.

Here's how you would compute that equation, to my knowledge.

Code:
`p = a (r ( (pow( (1+r), n) ) ) / ( (pow( (1+r), n ) -1 ) ) )`
is it man pow((1+r), n)
or is it pow((1+r), n)
and i put that at the beggining of my function right? next to my curly brace?
No, first you have to get input from the user, about how much the loan is, the interest rate, and lenght.

10. ok. thanks man. i think i get it=) i really appreciate it... I hate being so elementary all of a sudden. i feel really annoying.

11. Originally Posted by newcstudent
ok. thanks man. i think i get it=) i really appreciate it... I hate being so elementary all of a sudden. i feel really annoying.
Your welcome, and dont feel annoying, to be honest, im bored, so this helps "entertain" me

If you still can't manage to get it to work come on back, and ill show you how to do it

12. thanks. i'm sure i'll be back in like 5 minutes. maybe 10

13. Originally Posted by newcstudent
thanks. i'm sure i'll be back in like 5 minutes. maybe 10
I'll be waiting, and don't feel discouraged, theres only one way to learn. Part of being a good programmer is being able to ask questions, and seek assistance from others who can give it, and theres nothing wrong with that.

14. #include <stdio.h>

{
float r, n, a, p

printf("what is the interest rate?\n");

scanf("%f", &amount);

return 0;
}

so far... is this anywhere near close?

my assignment is excersize 2 at this url if you wanna check it for me.

http://cs.clark.edu/~cowen/CSE121/As...ssignment.html

15. hehe i forgot main (void)