end of file before left brace

Hi I'm new to c++ I have learned some and i've been working on a factorial program to give the factorial of a # 1-20. I have all my code worked out and everything seems fine I've been working on this for some time now and I just can't seem to find my problem. Heres all the code i have up to the end of file:

#include <iostream>

using namespace std;

float Num1;
float Num2 = Num1 - 1;
float Num3 = Num2 - 1;
float Num4 = Num3 - 1;
float Num5 = Num4 - 1;
float Num6 = Num5 - 1;
float Num7 = Num6 - 1;
float Num8 = Num7 - 1;
float Num9 = Num8 - 1;
float Num10 = Num9 - 1;
float Num11 = Num10 - 1;
float Num12 = Num11 - 1;
float Num13 = Num12 - 1;
float Num14 = Num13 - 1;
float Num15 = Num14 - 1;
float Num16 = Num15 - 1;
float Num17 = Num16 - 1;
float Num18 = Num17 - 1;
float Num19 = Num18 - 1;
float Num20 = Num19 - 1;

int main()
{


Any help fixing this would be helpful or if you need more info please say so I'm pretty new to this.
Are you familiar with loop structures? You obviously need one if you're going to write a non-recursive factorial function.

1
2
3
4
5
6
7
8
9
10
11
int main()
{
    cout << "Enter an integer: ";
    int n;
    cin >> n;
    long long int fact = 1;
    int i;
    for (i = n; i > 0; i--) fact *= i;
    cout << "\n" << n << "! = " << fact << endl;
    return 0;
}


You need to add something so that you take care of 0!.
umm i do know do-while loops, yes. let me try that
I did add a do-while loop and im getting the same error. and I probably should've said this earlier but the way i'm doing mine it's with a bunch of if and else if statements for each variable pretty much above mainly because that was the only way i know how to do it if that may be the problem.
The only way to do a factorial by if ... else is by exhaustion i.e. list all the cases, might as well used a look up table from the start?

-What error? Please show us the code.
Topic archived. No new replies allowed.