0

Hello good people of YA programming section I really need some help here, I made a function to find me the multiplication of the factorial of any number that I input but if I put say 100 it only gives back 0, when it should give 5050, maybe its the size of the ints but ints cant take like 2 Billion something, I dont know if anyone notices anything:

#include <stdlib.h>
#include <iostream>
using namespace std;
int fakt(int n);
int faktM(int n1);
int main(){
int factoriel, m, factoriel2;

cout<<"Enter Number: "<<endl;
cin>>m;
factoriel = fakt(m);
factoriel2 = faktM(m);
cin.get();
system("PAUSE");
return 0;
}

int fakt(int n){
int c, fact;
c = n;
while (c > 0){
cout<<" "<<c<<endl;
c=c-1;
}

return c;
}

int faktM(int n1){
int fact = 1;
int i;

for(i = 1; i <= n1; ++i){
fact *= i;
}

cout<<"multiplication: "<<fact<<endl;
cin.get();
return fact;

}

THANKS FOR ANY HELP

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by WaltP
0

Format your code so it can be read and followed easily by others.

You calculated the values in the functions but never returned them.

[edit]Sorry, your formatting caused me to misread the code. See?[/edit]

Edited by WaltP: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.