What do I need to do to fix the uninitialized error on my program? The program is suppose to print the number of divisors a number has but keeps displaying an error saying the variable c is uninitialized.
/*
/ Name: Ralph Lee Stone
/ Date: 10/10/2013
/ Project: RLStone3_HW_08
/ Description: This program gets a positive value and determines the number of divisors it has.
*/
#include
using namespace std;
int DivisorCount(int x)
{
int counter = 0;
for(int c; x < c; c++)
{
if (x%c==0)
counter++;
}
return counter;
}
int main()
{
int x;
cout << "Please a positive value: ";
cin >> x;
cout << x << "has this many divsors: " << DivisorCount(x);
}
No comments:
Post a Comment