Finding possible factors. Tried, need someone to modify. Algorithm Included


Factor Algorithm

Prompt the user for a positive integer

num <--- number read from keyboard

count <--- 1

while count <= num

if remainder of num divided by count is 0 then

output that count is a factor

end if

count <--- add one to count

end while

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# include <iostream>
using namespace std;
int main ()
{
int num;
cout<<"Enter A Positive Integer:";
cin>>num;
for(int count=1;count<=num;)
{
if (num%count==0)
cout<<"It Is A Factor"<<endl;

count=count+1;
}
return 0;
}
What is the problem?

The code seems to work fine for me. Just add something before return, so that the program doesn't end immediately and you can see the output.
Topic archived. No new replies allowed.