Wednesday, 18 June 2014

C++ program to check whether a given number is abundant number or not



Here is a C++ program to check whether a given number is abundant number or not


 SOURCE CODE OUTPUT
#include<iostream>
using namespace std;
int main()
{
    long sum=0,x;
    cout<<"Enter the value of x ";
    cin>>x;
    for(int i=1;i<x;i++)
        if(x%i==0)
            sum+=i;
    if(sum>x)
        cout<<"Given number is abundant number ";
    else
        cout<<"Given number is not abundant ";
    return 0;
}

Any questions regarding to program please write in comments.

No comments:

Post a Comment