Code:
#include <iostream>

int triangle(int);

int main()
{
    using namespace std;

    // Declare a variable as fact_num that represent factorial number
    int fact_num;

    // Promt user for input
    cout << "Please enter a number: ";
    cin >> fact_num;
    cout << "Your factorial number is: " << triangle(fact_num) << endl;
    system("pause");
    return 0;
}

    // The function body. That's the function definition
    int triangle(int fact_num){
        int n;
        int sum = 0;
        for(n = 1; n <= fact_num; n++){
            sum += n;
            return sum;
        }
}
Well...This is not a working programming because of the additional curly brace of the for loop. Hence, the test for the factorial doesn't work. But without the curly brace, it works fine. My question is why? How come it doesn't with the curly brace included for the for loop?