FACTOR PROGRAM USING SCOPE RESOLUTION OPERATOR(::)

//program to input any number and display factor using scope resolutions operator(::)

#include<iostream> 
using namespace std;
class calculate //
{
    public:  // Access specifier 
    int factor(int); 
};
int calculate::factor(int num)  // Using scope resolution operator
{
    cout<<"The factorial of "<<num <<endl;
    for(int i=1; i<=num; i++) 
    {
        if(num % i == 0)
            cout<<i<<endl;
       
    }
}
int main()
{
    calculate obj;  // Declare an object of class calculate
    int num;    // Data Members 
    cout << " Enter the number that you like :" <<endl;
    cin >> num;
    obj.factor(num);  
    return 0;
    
}

//wap to input any number and display it's factor using scope resolution operator


#include<iostream> 
using namespace std;
class calculate //
{
    public:  // Access specifier 
    int factor(int); 
};
int calculate::factor(int num)  // Using scope resolution operator
{
    cout<<"The factorial of "<<num <<endl;
    for(int i=1; i<=num; i++) 
    {
        if(num % i == 0)
            cout<<i<<endl;
       
    }
}
int main()
{
    calculate obj;  // Declare an object of class calculate
    int num;    // Data Members 
    cout << " Enter the number that you like :" <<endl;
    cin >> num;
    obj.factor(num);  
    return 0;
    
}

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.