A simple factorial program
Trying a simple factorial program but it prints out 1 all the time. any help ...
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
#include <iostream>
using namespace std;
int main()
{
int n=6, total=1;
while(n<=0){
total=total*n;
n--;
}
cout<<total;
}
|
n is 6. loop while n is less than or equal to 0. How many iterations does this loop run?
SHIT. sorry for asking such a basic question. thanx peter87
Topic archived. No new replies allowed.