Answer the question
In order to leave comments, you need to log in
Why doesn't the C code work?
#include <stdio.h>
int main()
{
float s = 0;
float a;
int i = 1;
while(s>=0,0001)
{
a = 1/(pow(i,4)+4*pow(i,2)+1);
s -= a;
i++;
}
printf("%f",&a);
return 0;
}
Answer the question
In order to leave comments, you need to log in
So far I see
No need to take the address from a.
1) Fractional numbers in all PL are written through a dot. For some reason (parallel loops), C has a "comma" operation, so the code can even compile.
2) The loop will not be executed even once, because 0 < 0.0001.
while(s>=0,0001)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question