While loop error: "Uninitialized local variable used"

ساخت وبلاگ

Vote count: 0

I'm doing an assignment where I modify a program that calculates the factorial of numbers so that the program terminates when the user enters the number '0'. Here is the code:

#include #include using namespace std;
int main()
{ unsigned int numb; unsigned long fact = 1; while (numb > 0) { cout << "Enter a number: "; cin >> numb; for (int j = numb; j > 0; j--) { fact *= j; cout << "Factorial is " << fact << endl; } } return 0;
}

However, I keep getting getting this error message:

error C4700: uninitialized local variable 'numb' used

What am I doing wrong?

asked 31 secs ago

back soft...
ما را در سایت back soft دنبال می کنید

برچسب : نویسنده : استخدام کار backsoft بازدید : 270 تاريخ : شنبه 26 فروردين 1396 ساعت: 7:29