# What's wrong with this code ?

#include <stdio.h>

int main()
{
int dia,Dia;
float pi=3.14,area;

printf("enter inner diameter of a washer in centimeter : ");
scanf("%d",& dia);
printf("enter outer diameter of a washer in centimeter:");
scanf ("%d",& Dia);

area =pi* ((1/4)*(Dia)^2-(1/4)*(dia)^2);

if (dia > Dia){

}else{
printf ("the Area of a washer is %f squarecentimeters" ,area);
}

return 0;
}

+1 vote
answered Jun 8 by (160 points)
For putting power, one must use the pow function defined under #include<math.h>
answered Jun 8 by (140 points)
You don't use ^ in c language. Instead you should call library (math.h) and try using pow() function. It'll work
answered Jun 8 by (140 points)
1/4 between brackets will likely evaluate to 0. Try (pi*Dia*Dia)/4.0 instead.

Furthermore, the check for Dia > dia could be moved at the beginning, so to avoid computing area in case dia > Dia.
+1 vote
answered Jun 8 by (3,880 points)
In C, you don't use ^ to represent a power. Instead, within the math.h system header file, there is a pow() function.

pow(x, y) where x is raised by y, which are passed in as double data types.
answered Jun 14 by (140 points)

their instead of multiplying 1/4 each time you can take common and multiply once.

answered Jun 25 by (140 points)
^ its an bit wise operator.In c we can take the power the number using pow(x,y) which is in the #include<math.h>

1.use #include<math.h>

2.replace ^ ----> pow(x,y)

here x is the base value. y is the power value
answered Jun 26 by (140 points)
#include <stdio.h>
#include<math.h>

int main()
{
int d,D;
float pi=3.14,area,k;

printf("enter inner diameter of a washer in centimeter : ");
scanf("%d",& d);
printf("enter outer diameter of a washer in centimeter:");
scanf ("%d",& D);
printf("D and d are %d and %d respectively ",D,d);
k=(pow(D,2)-pow(d,2));
area=pi*k/4;

if (d > D){

}else{
printf ("the Area of a washer is %f squarecentimeters" ,area);
}

return 0;
}

try this

hope it helps
answered Jul 6 by (140 points)
CHECK THIS OUT

#include <stdio.h>

int main()
{
int dia,Dia;
float area;

printf("enter inner diameter of a washer in centimeter : ");
scanf("%d",& dia);
printf("enter outer diameter of a washer in centimeter:");
scanf ("%d",& Dia);

area =0.785*((Dia)*(Dia)-(dia)*(dia));

if (dia > Dia){