help me please

why i cant get the answer?its different from what i calculate with the calculator...help me please...

/this program use to calculate the volume of the given shapes
#include<iostream>
#include<conio>
main()
{
float num, capsule, cone, cylinder, hemisphere, pyramid, length, height, radius;
const float pi=3.142;
cout<<"Please select your shape by entering the number"<<endl;
cout<<"1. Capsule"<<endl<<"2. Cone"<<endl<<"3. Cylinder"<<endl<<"4. Hemisphere"<<endl<<"5. Pyramid"<<endl;
cout<<"The number you have selected is ";
cin>>num;
if (num==1)
{
cout<<"Please enter the radius : ";
cin>>radius;
cout<<"Please enter the side length : ";
cin>>length;
capsule=(pi*(radius*radius)*((4/3)*radius+length));
cout<<"The volume of the capsule is "<<capsule<<endl;
}

else if (num==2)
{
cout<<"Please enter the radius : ";
cin>>radius;
cout<<"Please enter the height : ";
cin>>height;
cone=(1/3)*(pi*(radius*radius)*height);
cout<<"The volume of the cone is "<<cone<<endl;
}

else if (num==3)
{
cout<<"Please enter the radius : ";
cin>>radius;
cout<<"Please enter the height : ";
cin>>height;
cylinder=(pi*(radius*radius)*height);
cout<<"The volume of the cylinder is "<<cylinder<<endl;
}

else if (num==4)
{
cout<<"Please enter the radius : ";
cin>>radius;
hemisphere=((2/3)*pi*(radius*radius*radius));
cout<<"The volume of the hemisphere is "<<hemisphere<<endl;
}

else if (num==5)
{
cout<<"Please enter the length : ";
cin>>length;
cout<<"Please enter the height : ";
cin>>height;
pyramid=((1/3)*(length*length)*height);
cout<<"The volume of the pyramid is "<<pyramid<<endl;
}

else
{
cout<<"The number you have entered is not in the list"<<endl;
}
getch();
return 0;
}
What is the value of the expression 4/3? Since 4 and 3 are both integers, 4/3 results in an integer. Similar issue for 1/3, 2/3, and 1/3.

The expressions 4.0/3, 4/3.0, and 4.0/3.0 are all of type double.

i got it...thanks a lot
Topic archived. No new replies allowed.