a number is perfect if it is equal to the sum of its proper
divisor..

6 is perfect number coz its proper divisors are 1,2 and
three.. and 1+2+3=6...

a number is deficient if the sum of its proper divisor is
less than the number..
sample: 8 is deficient, coz its proper divisors are 1,2 and
4, and 1+2+4=7.

abundant number, if the sum of its proper divisor is greater
than the number..
sample..12 is abundant coz 1+2+3+4+6=16 which is geater than 12.

now write a program that prompts the user for a number, then
determines whether the number is perfect,deficient and
abundant..

Answer Posted / samim

#include<conio.h>
#include<stdio.h>
int f(int x)
{ int i,c,a=0;
for(i=1;i<x;i++)
{ c=x%i;
if(c==0)
a+=i;
}
return a;
}
void main()
{ int x;
clrscr();
printf("\nenter a integer number:\n");
scanf("%d",&x);
printf("%d",f(x));
if(f(x)==x)
printf("\nthis number is prefect");
if(f(x)>x)
printf("\nthis number is abundant");
if(f(x)<x)
printf("\nthis number is deficient");
getch();
}

Is This Answer Correct ?    5 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is structure in c language?

619


Why is C language being considered a middle level language?

654


Explain enumerated types in c language?

606


What is the acronym for ansi?

631


What is output redirection?

691






What is meant by keywords in c?

618


How can I sort a linked list?

635


What are the header files used in c language?

589


Why main function is special give two reasons?

948


What is bin sh c?

582


How do I swap bytes?

628


What is a newline escape sequence?

665


Explain what is a 'locale'?

585


What header files do I need in order to define the standard library functions I use?

539


write a c program to print the next of a particular no without using the arithmetic operator or looping statements?

3188