Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#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

image text in transcribed

#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

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

More Books

Students also viewed these Databases questions

Question

=+j Explain IHRMs role in global HR research.

Answered: 1 week ago

Question

=+j Describe an effective crisis management program.

Answered: 1 week ago