#include<stdio.h>
int main(){
float a, pi = 3.14, r, c, d, h;
printf("Program to calculate area of circle and volume of cylinder \n");
printf("select what you want to find?\n1.Area of circle\n2.Volume of cylinder\n");
scanf("%f", &c);
if (c == 1)
{
printf("Select unit\n1.CM\n2.Meter\n ");
scanf("%f", &d);
if (d == 1)
{
printf("enter radius in cm\n");
scanf("%f", &r);
a = (pi * r * r) / 100;
printf("the area of circle is \n%f cm", a);
}
if (d == 2)
{
printf("enter radius in meter\n");
scanf("%f", &r);
a = pi * r * r;
printf("the are of circle is \n%f meter", a);
}
else
{
if (c == 2)
{
printf("select unit\n1.cm\n2.meter\n");
scanf("%f", &d);
}
if (d == 1)
{
printf("enter radius in cm\n");
scanf("%f", &r);
printf("enter height in cm\n");
scanf("%f", &h);
a = (pi * r * r * h) / 100;
printf("the volume of cylinder is\n%f cm", a);
}
if (d == 2)
{
printf("enter radius in meter \n");
scanf("%f", &r);
printf("enter the height of cylinder in meter \n");
a = pi * r * r * h;
printf("the volume of cylinder is\n%f meter", a);
}
}
}
return 0;
}
What is the problem with this code the area of circle is coming correctly but but the volume of cylinder is not calculating. What is wrong in this code please explain with reason? the area of circle section is working perfectly but the volume of cylinder section is not please help me
Aucun commentaire:
Enregistrer un commentaire