Multiple definition of 'main'

the program i am writing is to calculate the volume of a cylinder. however, an error is occurring saying that there is a multiple definition of 'main'

this is what i have:


# include <iostream>
# include <string>
using namespace std;

int main ()
{
double height, radius, pi, vol;
string unit;

cout << "Enter height of cylinder\n";
cin >> height;
cout << "Enter radius of cylinder\n";
cin >> radius;
cout << "Enter unit\n";
cin >> unit;

pi = 3.14;
vol = pi * (radius * radius) * height;
cout << "The volume of the cylinder is " << vol << " cubic " << unit;
cout << endl;

system ("pause");
return 0;
}
Last edited on
Did you add this file to an existing project?

You need to create a new project to make a new program. Adding a new cpp file just builds on your previous program.
i was making a project and under the project i wanted to have multiple files. the project consists of several different mathematical calculations. is there any way of me doing the multiple files? or should i just do multiple projects?
Well basically 1 project = 1 program. And you can only have 1 main() per program (otherwise how is the computer supposed to know which main you want to use?).

You can have multiple calculations in the same program, but then you have to have some kind of interface for where the user selects which calculation they want to use.

If you want each calculation to have its own program, then they must all be their own project.
thank you very much
Topic archived. No new replies allowed.