My program is giving me factors but its also giving me other numbers i put the variables as int but i think its still using the decimal places for the modulus function here is my program. any help would be greatly appreciated.

#include <iostream>

#include <iomanip>

using namespace std;

int main(void)

{

int num,

factor = 2,

counter = 0;

cout << "Please Enter a Positive Number: " << endl;

cin >> num;

if ((cin.fail()) || (num < 0))

{cin.sync();

cin.clear();

cout << "Positive Numbers Only, Please Re-Enter: " << endl;

cin >> num;}

do

{

if ((num % factor)!= 0)

factor++;

else if ((num % factor) == 0)

(num = num / factor);

cout << setw (10) << factor << " ";

counter++; factor++;

{if (counter % 4 == 0)

cout << endl;}

}

while (factor <= num);

cin.ignore(2);

return 0;

}

#include <iostream>

#include <iomanip>

using namespace std;

int main(void)

{

int num,

factor = 2,

counter = 0;

cout << "Please Enter a Positive Number: " << endl;

cin >> num;

if ((cin.fail()) || (num < 0))

{cin.sync();

cin.clear();

cout << "Positive Numbers Only, Please Re-Enter: " << endl;

cin >> num;}

do

{

if ((num % factor)!= 0)

factor++;

else if ((num % factor) == 0)

(num = num / factor);

cout << setw (10) << factor << " ";

counter++; factor++;

{if (counter % 4 == 0)

cout << endl;}

}

while (factor <= num);

cin.ignore(2);

return 0;

}

Topic archived. No new replies allowed.