不是完全理解,求
要求是这样的:create a text-based, menu-driven program that allows the user to choose whether to calculate the circumference of a circle, the area of a circle or the volume of a sphere. The program should then input a radius from the user, perform the appropriate calculation and display the result. Use an array of function pointers in which each pointer represents a function that returns void and receives a double parameter. The corresponding functions should each display messages indicating which calculation was performed, the value of the radius and the result of the calculation.
以下是我写的程序:
#include<stdio.h>
#define P 3.14
void main()
{
int choice, r;
float C,A,V;
printf("Press 1, calculate the circumference of a circle.\n");
printf("Press 2, calculate the area of a circle.\n");
printf("Press 3, calculate the volume of a sphere.\n");
printf("Enter your choice: ");
scanf ("%d", &choice);
switch(choice)
{
case 1:
printf("Please enter the radius: ");
scanf ("%d",&r);
C = 2*P*r;
printf("\n The circumference of circle is %.2f",C);
break;
case 2:
printf("Please enter the radius: ");
scanf ("%d",&r);
A = P*r*r;
printf("The area of a circle is %.2f",A);
break;
case 3:
printf("Please enter the radius: ");
scanf ("%d",&r);
V = 4/3*P*r*r*r;
printf("The volume of a sphere is %.2f",V);
break;
}
}
我知道不能完全符合要求,但是又没什么思路,哪位大侠给指条明路,多谢啊!!