Functions not returning values

I am writing a program to yield the result of a factorial with an equation rather than using if statements. The goal of the problem is to use functions to get the answer, rather than just doing the equation in void main. Each of the function definitions give the error C4716: 'name of function' : must return a value. The program is written in Microsoft Visual Studio 2010. I have the formula broken into the three parts firstPart, squareRt, and the fullEq. I have come back to the problem numerous times and have been staring at it for hours, any help would be greatly appreciated.

#include <iostream>
#include <iomanip>
using namespace std;
const double PI = 3.14159265;
double firstPart (double);
double squareRt (double);
double fullEq (double, double);

void main()
double ans, n, firstAns, squareAns;

while (true)
cout << "Enter n: ";
cin >> n;

firstAns = firstPart (n);
squareAns = squareRt (firstAns);
ans = fullEq (n, squareAns);

cout << fixed << setprecision (5);
cout << endl << int (n) << "! equals " << ans << endl << endl;

double firstPart (double x)
(2 * x + double (1) / 3);

double squareRt (double x)
sqrt (x * PI);

double fullEq (double x, double y)
(pow (x, x) * exp (-x) * y);
Your functions are not returning anything, as the error states.

double firstPart (double x)
// You have to return the result
double result = (2 * x + double (1) / 3);
return result;
Wow, I feel really dumb. I should have seen that. Thanks for responding.
Topic archived. No new replies allowed.