I have this below file. I am trying to run it in visual studios 2010. But it keeps giving me an error saying that I need to include the header file stdafx.h. But this file is nowhere to be seen in the list of header files.
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
int choice();
double cylinder_volume();
double cone_volume();
double sphere_volume();
void display_result(double volume);
int main ()
{
int option;
double volume;
option=choice();
if (option==1)
{
volume=cylinder_volume();
display_result(volume);
}
else
if (option==2)
{
volume=cone_volume();
display_result(volume);
}
else
if (option==3)
{
volume=sphere_volume();
display_result(volume);
}
return 0;
}
int choice()
{
int option;
cout<<"What would you like to calculate the volume of: ";
cout<<"\nPress 1 for cylinder. ";
cout<<"\nPress 2 for cone. ";
cout<<"\nPress 3 for sphere. ";
cin>>option;
return option;
}
double cylinder_volume()
{
const double pi=3.14159;
double height,radius,volume;
cout<<"Enter the height of the cylinder: ";
cin>>height;
cout<<"\nEnter the radius of the cylinder: ";
cin>>radius;
volume=pi*radius*radius*height;
return volume;
}
double cone_volume()
{
const double pi=3.14159;
double height,radius,volume;
cout<<"Enter the height of the cone: ";
cin>>height;
cout<<"\nEnter the radius of the cone: ";
cin>>radius;
volume=(1/3)*pi*radius*radius*height;
return volume;
}
double sphere_volume()
{
const double pi=3.14159;
double radius,volume;
cout<<"\nEnter the radius of the sphere: ";
cin>>radius;
volume=(4/3)*pi*radius*radius*radius;
return volume;
}
void display_result(double volume)
{
cout<<volume;
}