Friday, February 10, 2012

calculate all factor of a number

//program to calculate total no. of factor of a number
// factor of 10 is -- 1, 2, 5, 10 (total is 4)

#include<iostream>
using namespace std;

int main()
{
    int n, i, c=0;
   
    cout << "Enter the number: ";
    cin >> n;
    

    for(i=1;i<=n;i++)
    {
        if( n%i == 0)
        c++;
    }


    cout << "The number of factor of the number " << n << " is: " << c; 
}

No comments:

Post a Comment