Question
Need help with code not getting the correct output Code is in C /* * Computing the Weight of a Batch of Flat Washers */
Need help with code not getting the correct output
Code is in C
/*
* Computing the Weight of a Batch of Flat Washers
*/
#include
#define PI 3.14159
int
main(void)
{
double innerradius; /* input - radius of a inner circle */
double outerradius; /* input - radius of outer circle */
double idiameter; /* diameter of inner circle */
double odiameter; /* diameter of outer circle */
double rimarea; /* area of a rim */
double matden; /* input - density of material in grams/cm^3 */
double thickness; /* input - thickness of material in centimeters */
double weight; /* weight of a single washer */
double quantity; /* number of washers */
double batch; /* weight of a batch of washers */
/*
* Calculating the radius of both the inner and outer circles
*/
printf("Enter the inner diameter> ");
scanf("%lf", &idiameter);
printf("Enter the outer diameter> ");
scanf("%lf", &odiameter);
innerradius = idiameter / 2.0;
outerradius = odiameter / 2.0;
printf("The inner radius is %lf", &innerradius);
printf("The outer radius is %lf", &outerradius);
/*
* Calculating the area of the rim
*/
rimarea = PI * innerradius * innerradius - PI * outerradius * outerradius;
printf("Area of the flat washer is %f ", &rimarea);
/*
* Finding material density and thickness
*/
printf(" Enter the density of the material in grams/cm cubed ");
scanf(" %lf ",&matden);
printf(" Enter the thickness of the flat washer ");
scanf(" %lf ",&thickness);
/*
* Finding the weight of a single flat washer
*/
weight = rimarea * matden * thickness;
printf("Weight of a single flat washer is %f ",&weight);
/*
* Finding the weight of a batch of flat washers
*/
printf("Number of flat washers in a batch - ");
scanf(" %lf ",&quantity);
batch = weight * quantity;
/*
* Displaying the weight of the batch of washer
*/
printf(" The weight of the batch of washers is %f grams ",&batch);
return (0);
}
Step 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