• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

[C/C++]Help me!!!

Core_

Well-Known Member
Joined
Jul 9, 2010
Messages
1,557
Solutions
1
Reaction score
50
I need some help with my homework, i have to make a program that gives you the factorial of a number let me explain it, the shit ask you for a number, ok a fucking variable lets say you put 5 and then it multiplies 1x2x3x4 if you put 8 then 1x2x3x4x5x6x7 and so..

Im trying to make it right now but if some one can help me that will be cool

EDIT: maybe is easier just fix it, im having this error:
hss0uprtQ8.png


Code:
#include <iostream>
using namespace std;

int main () {
    
    int number;
    
    cout << "Put a fuckin number" << endl;
    cin >> number;
    
    for (int factorial=1 ; factorial <= number ; factorial++ ) {
        factorial = factorial*factorial;
        }
        
    cout << "the factorial is: " <<endl;
    cout << factorial << endl;
    
    system("pause");
    return 0;
}
 
Last edited:
I need some help with my homework, i have to make a program that gives you the factorial of a number let me explain it, the shit ask you for a number, ok a fucking variable lets say you put 5 and then it multiplies 1x2x3x4 if you put 8 then 1x2x3x4x5x6x7 and so..

Im trying to make it right now but if some one can help me that will be cool

EDIT: maybe is easier just fix it, im having this error:
hss0uprtQ8.png


Code:
#include <iostream>
using namespace std;

int main () {
    
    int number;
    
    cout << "Put a fuckin number" << endl;
    cin >> number;
    
    for (int factorial=1 ; factorial <= number ; factorial++ ) {
        factorial = factorial*factorial;
        }
        
    cout << "the factorial is: " <<endl;
    cout << factorial << endl;
    
    system("pause");
    return 0;
}

factorial is out of the for() scope when outputting factorial at the end.
it should either be defined within int number or outside the int main() at the top.

and the system error, you have to include: stdlib.h
...but I don't recommend you to use system as it is operating system dependant.

The final product should look a bit like this:
Code:
#include <iostream>
#include <stdlib.h>
using namespace std;

int main ()
{

    int number;
    int factorial = 1;

    cout << "Put a fuckin number" << endl;
    cin >> number;

    for (; factorial <= number ; factorial++ )
    {
        factorial = factorial*factorial;
    }

    cout << "the factorial is: " <<endl;
    cout << factorial << endl;
    system("pause");
    return 0;
}


BTW: I just fixed your compiling errors. I'm not sure if it does what you want.
 
Last edited:
Back
Top