The task was to find the Area and Volume of a sphere using functions and an additional task was provided to give a function to find the powers of the radius separately (using another function) and then call it in the functions of area and volume. I can't figure out the way to call the radius function for different powers. The formula for Surface area is 4*PI*r(power 2) The formula for the Volume is 4/3 *(PI)*r(power 3)
#include <stdio.h>
#include <math.h>
#include <conio.h>
#define PI 3.142
float surface(int x);
float volume(int y);
int radius();
int main()
{
int r;
float a, b;
clrscr();
printf("Enter the radius :");
scanf("%d", &r);
a=surface(r);
b=volume(r);
printf("Surface Area =%f", a);
printf("\n");
printf("Volume =%f", b);
getch();
return 0;
}
int radius(int z)
{
int f;
f=z*z;
return (f);
}
float surface(int x)
{
float s;
s = 4*PI*radius(x);
return (s);
}
float volume(int y)
{
float v;
v = (4*PI*radius(y)/3);
return (v);
}
I was also instructed to "Refrain from using Arrays or others methods of solving this question."
I cant figure out the way to call the radius function for different powers. An explanation or the correct way to solve this would be helpful!