This is written in C. The program works, but the calculation is wrong, can someone tell me what I am doing wrong?
Thank You
Code:
#include "stdafx.h"
#include <math.h>
#using <mscorlib.dll>
using namespace System;
// Function prorotypes
void sphere_volume (double);
// PI is a constant
const double PI=3.14159;
int _tmain()
{
// Integer local to Main to store initial radius value
double r;
printf("Please Enter A Positive Radius Value\n");
scanf("%lf", &r);
// If Else Function To Make Sure The User Types A Positive and Not A Negative Integer.
if (r >= 0)
sphere_volume (r);
else
printf("You Must Enter A Positive Integer!!!! Not A Negative Integer!!!\n");
return 0;
}
// This Is The Fnction That Does The Calculations For The Volume.
void sphere_volume (double radius)
{
double radius_cubed;
double exponent=3;
double volume;
printf("This Is The Test To See If R Was Passed To The Function: %lf\n", radius);
radius_cubed=pow(radius, exponent);
volume=(4/3)*PI*radius_cubed;
printf("The Volume Of The Sphere is %lf\n", volume);
}