Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
How to calculate the shaded area in a diagram with c programming?
Write a program to calculate the shaded area in the diagram. The shaded area is the difference between the areas of the two circles with radii r1 and r2 respectively. The values of r1 and r2 are to be initialised in the program. Define the value of pie as 3.1416
Sample output
Radii of bigger shaded area is and smaller circles are 4.500000 and 2.00000 cm . The shaded area is 51.051000 sq cm
2 Answers
- ?Lv 77 years agoFavorite Answer
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
const double pi = 3.1416;
double r1, r2, diff;
printf("Enter r1: ");
scanf("%lf",&r1);
printf("Enter r2: ");
scanf("%lf",&r2);
diff = pi * (r1*r1 - r2*r2);
printf("Radii of bigger shaded area is and smaller circles are %f and %f cm . The shaded area is %f sq cm\n", r1, r2, diff);
return 0;
}
- ChrisLv 77 years ago
I'm giving you the solution since this is an absolute no-brainer, even without the diagram:
float r1 = 4.5;
float r2 = 2.0;
float pi = 3.1416;
float area = r1*r1*pi - r2*r2*pi;
cout << "Radii of bigger and smaller circle are " << r1 << "cm and " << r2 << "cm. The shaded area is " << area << "cm²";