Pull the function definition for fallingDistance outside of the main function. Also, in the definition, you don't want the semicolon at the end of double fallingDistance(int t);
If you're using a decent indentation style you should easily see that you're trying to define a function inside another function which is not allowed in C++.
#include "stdafx.h"
#include <iostream>
#include <math.h>
usingnamespace std;
//function prototype
double fallingDistance(int t = 0);
int _tmain(int argc, _TCHAR* argv[])
{
int t = 0; //time
double d = 0; //distance
std::cout << "I will calculate the distance an object falls in 12 seconds\n";
for(int i = 1; i <= 12; i++)
{
d = fallingDistance(i);
std::cout << i << "seconds " << d << "feet \n";
}
return 0;
// The following code must be moved outside of the closing brace of main().
double fallingDistance(int t);
{
double d = 0;
constdouble g = 32.2;
d = (0.5 * g) * (pow(t, 2));
return d;
}
}