Im just making a simple pc dos program to calculate the volume of a sphere and for some reason it wont compile.
This line:
fltVolume = ((4/3)*PI*(fltRadius^3));
Gives this error:
'^' : illegal, left operand has type 'float'
Now is this telling me you cant raise decimal numbers to powers?
- Code:
#include <stdio.h>
main(){
const float PI = 3.14159;
char chrRadius[20];
float fltRadius;
float fltVolume;
puts("");
puts("Please enter the radius of the sphere wich you wish to find the volume of:");
fgets(chrRadius, sizeof(chrRadius), stdin);
sscanf(chrRadius, "%f", &fltRadius;);
//Do the math
fltVolume = ((4/3)*PI*(fltRadius^3));
printf("The vloume of the sphere is %;f.\n", fltVolume);
return 0;
}
This line:
fltVolume = ((4/3)*PI*(fltRadius^3));
Gives this error:
'^' : illegal, left operand has type 'float'
Now is this telling me you cant raise decimal numbers to powers?