Question: #include #define PI 3.1415926 int main() { double r,d,c,a; char letter; printf(Enter the radius of a circle: ); scanf(%lf, &r); printf(Choose (enter) one of the

 #include #define PI 3.1415926 int main() { double r,d,c,a; char letter;

#include #define PI 3.1415926

int main() { double r,d,c,a; char letter; printf("Enter the radius of a circle: "); scanf("%lf", &r); printf("Choose (enter) one of the following: D = calculate diameter. C = calculate circumference A = calculate area Your choice: "); scanf("%c", &letter); if(letter=='D'){ d=2*r; printf("Diameter: %1.3lf ", d); } else if(letter=='C'){ c=2*PI*r; printf("Circumference: %1.3lf ", c); } else if(letter=='A'){ a=PI*r*r; printf("Area: %1.3lf ", a); } else{ printf("Error. try again"); }

*Can you point out whats wrong with my code?

return 0; }

Write a C program that asks the user to enter a value for radius of a circle. It then displays the following options: D = calculate diameter C = calculate circumference A= calculate area If a valid option is entered, it prints the result of the calculation. Otherwise, it displays an appropriate message

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!