Heres the code, im pretty sure i missed something really stupid,
No matter what number i type i get "The number oyu type must be a positive number" so i guess the problem is either in my if statements in main or in the checkuserinput function, most likely in my if statements however, i cant find it. I'ts really annoying because it should be quite easy. I would really appreciate any help given.

EDIT: it worked before i added the if statements and the checkuserinput fucntion (which is lacking some functions i know, if you have some good advice please share it :) )

#include <iostream>

using namespace std;
int facultize (int user_input);
int checkuserinput (int user_input);
int main()
{
    int n;
    int inpchk;
    cout<< "Please type a number to find it's factorial; ";
    cin>> n;
    inpchk = checkuserinput (n);
    if (inpchk = 0)
        cout<< facultize (n);

    else if (inpchk = 1)
        cout<< "The number you type must be a positive number";

    else
        cout<< "Error, program terminated";

    return 0;
}
int facultize (int user_input) {
    int result = user_input;
    for (int i=user_input - 1;i>1;i--) {
        result = result * i;
    }
    return (result);
}
int checkuserinput (int user_input) {
    int res;
    if (user_input > 0) {
        res = 0;
    }
    else if (user_input <= 0) {
        res = 1;
    }
return (res);
}

In the if clause u need to use "==" and not = , because its defines a new value (with = ).
So change
if (inpchk = 0)
cout<< facultize (n);
else if (inpchk = 1)
To
if (inpchk == 0)
cout<< facultize (n);
else if (inpchk == 1)

Holy fuck im stupid:) i knew it was something really stupid, well thanks jen140:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.