Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is what I have so far of a c++ program to compute the factors of an input i

ID: 3651891 • Letter: T

Question

This is what I have so far of a c++ program to compute the factors of an input integer. What I'm stuck on is making the program repeat after the production of factors and how i would make the program say if a number is prime or not.

/*
File: factors.cpp
Created By:
Created On: 10/10/12

Synopsis:
*/

#include <iostream>
#include <iomanip>
#include <cstdlib>

using namespace std;

int main ()
{

int num = 0;
int count = 0;
int a = 1;


cout << "Enter an integer (0 to exit): ";
cin >> num;

while(num < 0)
{
cerr << "Illegal negative number."<< endl;
cout << "Enter an integer (0 to exit): ";
cin >> num;
}

if(num==0)
{
exit(10);
}

cout << "Factors of " << num << ": ";
for (int a = 1;a<=num; a++)
{
while (num % a ==0)
{
cout << a << " ";
a++;
}
}



return 0;
}

Explanation / Answer

#include #include #include using namespace std; int main () { int num = 1; while(num >0) { cout > num; int flag =0; if(num < 0) cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote