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
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 messageStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started