Help please. It won't output the right numbers.
Code:#include <iostream.h> int main() { float a,b,c,d,e,f,g; a,b,c,d,e,f,g = 1; float factorial; cout << "Push a number that you would like to factorialize." << endl; cin >> factorial; cout << "You chose " << factorial << endl; float factwhile; factwhile = factorial; while(factwhile > 0) { a = factorial - 1; factwhile = factwhile - 1; b = factorial - 2; factwhile = factwhile - 1; c = factorial - 3; factwhile = factwhile - 1; d = factorial - 4; factwhile = factwhile - 1; e = factorial - 5; factwhile = factwhile - 1; f = factorial - 6; factwhile = factwhile - 1; g = factorial - 7; factwhile = factwhile - 1; } float answer; answer = a*b*c*d*e*f*g; cout << answer << endl; cin.get(); return 0; }



LinkBack URL
About LinkBacks


