HomeC++

C++ Program to Find Factors of a Number

C++ Program to Find Factors of a Number
Like Tweet Pin it Share Share Email

C++ Program to Find Divisors of a Number.program takes number from the input and runs a while loop until the temporary variable reaches the given number. The temporary number is printed on the screen if the given number is completely divisible by the temporary variable.

C++ Program to Find Divisors of a Number

#include <iostream>
#include<conio.h>
using namespace std;
int main()
{
int n, i;
cout << "Enter the number:";
cin >> n;
cout << "Factors of " << n << " are: " << endl;
for(i = 1; i <= n; ++i)
{
if(n % i == 0)
cout << i << endl;
}
return 0;
}

Output of ProgramC++ Program to Find Factors of a Number

Comments (0)

Leave a Reply

Your email address will not be published. Required fields are marked *