0

#include <stdio.h> #include <string.h> #include <string.h> #include <stdlib.h> #include <math.h> #include <ctype.h> #include <cs50.h>

int main ( int argc, char *argv[] ){

double a=1; printf("%f\n",a); for (int i=0;i<33;i++){ a<<=i; printf("%f\n",a);}

}

1 Answer 1

0

It's working exactly as it's supposed to. You could plug the numbers in on paper and work it out in the order that is dictated by the parentheses and you'd get this:

a = 100,  b = 5

c=pow( ((a/b) / (a/pow(b,2))), -1);
c=pow( ((100/5) / (100/pow(5,2))), -1);
c=pow( ((20) / (100/25)), -1);
c=pow( (20 / 4, -1);
c=pow( (5, -1);
c = 1/5 = 0.20000020   (with error for floating point storage)

Interestingly, it doesn't matter what you put in for a, it will always end up with a result of 1/b. Ultimately, a in the denominator cancels a in the numerator and there's a similar cancellation of b, leaving one b in the numerator which is then inverted.

Perhaps you have the formula coded incorrectly?

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .