Hello, I have just got into learing to program (In C), and I'm having a problem with floating point.
It's a simple get the volume of a circle if given a radius problem.
#include <stdio.h>
char user[100];
float radius;
const float PI = 3.1415;
float volume;
int main()
{
printf("Enter radius of circle: ");
fgets(user, sizeof(user), stdin);
sscanf(user, "%f", &radius);
volume = ((4.0 / 3.0 * PI) * radius) ^ 3.0;
printf("The volume of the circle is %f\n", volume);
return (0);
}
Now I don't know if this message board has problems with posts having source code in them, but it's a short program, so don't kill me.
What I want to know from anyone that knows C, is to tell me if I did anything wrong, because when i compile the code, it brings up a error message saying illegal use of float point.
I belive the problem lies in with the squaring the problem by 3. Maybe you can't square floating point numbers? Or a special function or key to do it?
I dont know, please help.