Hello, people. I need help.
I need to write a program in C that uses a function to calculate the sum of all fractions 1/(a^4) for "a" values from 1 to x(which is scanf'ed), with 6 digits after the comma. I wrote the code:
The code seems to work (it works if I remove "1/", it DOES sum up all a^4's), but in the aforementioned case the answer is always 1.000000. The program seems to automatically round all values of 1/a*a*a*a to zero for a>1. How do I avoid this?Code:#include <stdio.h> float f; int function(int x) { int a=1; float e; while(a<=x) { e=1/(a*a*a*a); f=f+e; a++; } return(f); }
Thanks in advance