C++ Program to Display Factors of a Number.
#include <iostream.h>int main()
{
int n, i;
cout << "Enter a positive integer: ";
cin >> n;
cout << "Factors of " << n << " are: " << endl;
for(i = 1; i <= n; ++i)
{
if(n % i == 0)
cout << i << endl;
}
return 0;
}
Output
Enter a positive integer: 60
Factors of 60 are: 1 2 3 4 5 6 12 15 20 30 60
Tags:
C++ Program to Display Factors of a Number.
c++ programming
c++ programming by mskuthar
c++ programming c plus plus by mskuthar
factors of a number