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..



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

Answer / 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

More C Interview Questions

How can I prevent other programmers from violating encapsulation by seeing the private parts of my class?

1 Answers  


What is the benefit of using #define to declare a constant?

0 Answers  


What does static variable mean in c?

0 Answers  


In CMM or CMMI certified organizations,we assess only the standard software processes of the organization. We do not assess the organizations other functional departments like HR or Admin. Then how can we certify the entire organization as CMM level company?? We have assessed only software related activities. Right. There is no relation with other departments like Accounts, HR or Admin. Then how can we claim that the whole company is a CMM certified company?

1 Answers   Melstar,


What is the use of bitwise operator?

0 Answers  






union { char ch[10]; short s; }test; test.s = 0xabcd; main() { printf("%d",ch[10]); }

3 Answers  


about c language

0 Answers  


What is the usage of the pointer in c?

0 Answers  


Write a program in C to convert date displayed in gregorian to julian date

0 Answers   HCL, Wipro,


print pattern 1 1 33 33 555 555 77777777 555 555 33 33 1 1

1 Answers   Winit,


void main() { char far *farther,*farthest; printf("%d..%d",sizeof(farther),sizeof(farthest)); }

3 Answers   ME, pspl,


Why is #define used?

0 Answers  


Categories