Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced MySQL 8 Discover The Full Potential Of MySQL And Ensure High Performance Of Your Database

Authors: Eric Vanier ,Birju Shah ,Tejaswi Malepati

1st Edition

1788834445, 978-1788834445

More Books

Students also viewed these Databases questions

Question

c. What groups were least represented? Why do you think this is so?

Answered: 1 week ago