Question: Enter the program below 2 ) Run program using input = 1 . Then, type 1 0 ( radius ) 3 ) Add function for

Enter the program below
2) Run program using input =1. Then, type 10(radius)
3) Add function for area of square. Then, add function for area of sphere
4) Test both functions (input =10).
5) Make sure your calculation is accurate
i need to see the out put and please run the program in C
Source code
#include
// Function prototypes
int input();
void output(float);
float areaOfCircle(int radius);
// driver code
int main()
{
float result;
int choice, num;
// printing menu
printf("Press 1 to calculate area of circle
");
printf("Press 2 to calculate area of square
");
printf("Press 3 to calculate area of sphere
");
printf("Enter your choice:
");
// taking input
choice = input();
// switch statement to print output according to the
// choice
switch (choice){
case 1: {
printf("Enter radius:
");
num = input();
result = areaOfCircle(num);
printf("Area of circle=");
output(result);
break;
}
case 2: {
printf("Enter side of square:
");
num = input();
result = num * num;
printf("Area of square=");
output(result);
break;
}
case 3: {
printf("Enter radius:
");
num = input();
result =4*(3.14* num * num);
printf("Area of sphere=");
output(result);
break;
}
default:
printf("wrong Input
");
}
printf("
");
return 0;
}
// function to take input
int input()
{
int number;
scanf("%d", &number);
return (number);
}
// function to print output
void output(float number){ printf("%f", number); }
//Area of a circle
float areaOfCircle(int radius)
{
return radius*radius*3.14;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!