The program fails to build most likely because you have no main() function
#include <iostream>
using namespace std;
int main (int argc, char** argv)
{
// your program here
return 0; // successful execution
}
ShawnCplus
Code Monkey
1,583 posts since Apr 2005
Reputation Points: 526
Solved Threads: 268
I'm not seeing a main function anywhere. do you have this code in a main function?
NathanOliver
Veteran Poster
1,084 posts since Apr 2009
Reputation Points: 215
Solved Threads: 189
http://www.cplusplus.com/doc/tutorial/program_structure/
From this link:
int main ()
This line corresponds to the beginning of the definition of the main function. The main function is the point by where all C++ programs start their execution, independently of its location within the source code. It does not matter whether there are other functions with other names defined before or after it - the instructions contained within this function's definition will always be the first ones to be executed in any C++ program. For that same reason, it is essential that all C++ programs have a main function.
Stick your code in a main function and try compiling and running it again.
#include <iostream>
using namespace std;
int main ()
{
double ounces;
cout << "Enter the box weight in ounces and press enter";
cin >> ounces;
double weightInMetricTons, numberOfCerealBoxes;
weightInMetricTons = ounces/35273.92;
numberOfCerealBoxes = 35273.92/ounces;
cout << "The weight in metric tons is/n"
<< weightInMetricTons << "and it takes/n"
<< numberOfCerealBoxes << "to equal a metric ton";
return 0;
}
VernonDozier
Posting Expert
5,527 posts since Jan 2008
Reputation Points: 2,633
Solved Threads: 711