getchar();
Type: Posts; User: JDD
getchar();
Well im obviously not smart enough to fix this >.<
#include <stdio.h>
#include <math.h>
int main(void)
{
double r, a, p, x, powr, n;
No, as far as i can tell everything should compile fine...
Are you sure you
#include <math.h>
'd.
powr = pow((double)x , (double)n);
Try that ;x
#include <stdio.h>
#include <math.h>
int main(void)
{
double r, a, p, x, powr, n;
p = (r * powr ) / ( powr - 1 );
Simple mistake ;x
Oh but of course, and my code = a lot of what i've shown you so far... don't worry.
Edit:
#include <stdio.h>
#include <math.h>
int main(void)
Alright, what im gonna do is write the program myself, how i would do it, post it, and you can compare, because that confused me ;x
Apologies, there was something wrong in the code i posted
#include <stdio.h>
#include <math.h>
int main(void) // good habit, i dont think your teacher would mind.
{
USE CODE TAGS :)
#include <stdio.h>
#include <math.h>
int main(void) // good habit, i dont think your teacher would mind.
{
float r, a, p;
It was never asked in this thread, getchar() works, and it doesnt knock performance, so why NOT use it.
Not necessarily , it likely shows a simple habit.
But most of the time the best...
It returns a double doesn't it? ;x
It's a start in the right direction, but along with adding main, please use code tags, ['Code]['/Code] tags, without the 's.
Oh, and
#include <math.h>
Oh thats right, the only way i can think of printing it, would be to...
int main()
{
int base, exp;
double powr;
char expc;
scanf("%i", &base) ;
printf("%i ^ %i = %i\n" , base, exp, pow(base, exp));
Try that.
Or, you can always error check.
int main()
{
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...
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
No, you could do exactly what i showed you.
Here's how you would compute that equation, to my knowledge.
p = a (r ( (pow( (1+r), n) ) ) / ( (pow( (1+r), n ) -1 ) ) )
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);
Are you sure theres no way to simplify the equation?
1. Input doesn't NEED to be initialized.
2. I agree that comparing an int to a float is wrong, and should be changed.
3. I assume he IS running his program from command line "like all real...
Posted in other topic.
Edit: Lets go through your code first... then ill post a fixed program...
: //Useless...
#include <stdio.h>
#include <math.h>
int main()
{