the programe output the sum of the factor of a number
entered by user and when he enter 0 the programe should display output with no result for 0
here is the code

#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
    int x,i;
    int z=1;
    int sum=0;

        while(cin>>x)
        {
            if(x!=0)
            {
        for(int i=1;i<x;i++)
        {
            if(x%i==0)
            {
                z=i;
            }
            if(x%i!=0)
            {
                continue;
            }
            sum+=z;
        }
            }
            if(x==0)
            {
                break;
            }
        }
cout<<"PERFECTION"<<" "<<"OUTPUT"<<endl;
if(sum==x)
{
    cout<<setw(5)<<x<<"  "<<"PERFECT"<<endl;
}
else if(sum>x)
{
    cout<<setw(5)<<x<<"  "<<"DEFICIENT"<<endl;
}
else if(sum<x)
{
    cout<<setw(5)<<x<<"  "<<"ABUNDANT"<<endl;
}
cout<<"END OF OUTPUT"<<endl;

return 0;

}

Recommended Answers

All 3 Replies

what do u mean by boom!

It's a link click it and read it. Here's another good one

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.