Code:
/*
Title: Spherical Crap
Name: BELIAL
Date: 30 AD
Description: Give the radius, and yee shall receive
the surface area and volume of a sphere...amen.
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
// XXX I removed <conio.h>, getch() does not work on my Linux machine :-(
// XXX I got rid of the diameter #define and "fixed" the below #define's
#define RADIUS_TO_VOLUME ((4/3)* 3.14*pow(radius,3))
#define RADIUS_TO_AREA (4*3.14*pow(radius,2))
// Function Prototype
void explain (void);
float get_radius (float a);
void calc_display (float radius); // XXX fixed the parameters of this function :-D
main()
{
float answer, t, e;
system("cls");
explain();
e=get_radius(t); // XXX 't' and 'e' are the same variables...interesting!
calc_display(e);
system("cls");
return 0; // XXX you returned 0! good job! (not many ppl remember this)
}
//Function definition
void explain (void)
{ puts("");
puts("");
}
float get_radius (float a)
{ printf("please give me the radius");
scanf("%f",&a);
return(a);
}
void calc_display (float radius) // XXX FIxed the parameters ;)
{
float volume = RADIUS_TO_VOLUME; // XXX added this to calculate the volume and area
float area = RADIUS_TO_AREA; // from the #define's.
printf("The area is %.3f and the volume %.3f", area, volume);
}