خرید بک لینک

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

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

صفحه بندی