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

what is the output for this question: main() { int i=1; printf("%d%d%d",i,i++,++i); }

9 Answers  


What are the different types of control structures?

0 Answers  


What language is windows 1.0 written?

0 Answers  


print a "hello" word without using printf n puts in c language

6 Answers  


Explain 'bit masking'?

0 Answers   EXL,






An organised method of depicting the use of an area of computer memory used to signify the uses for different parts of the memory a) swap b) extended memory c) memory map d) all of the above

0 Answers  


What are data types in c language?

0 Answers  


Differentiate between the = symbol and == symbol?

0 Answers  


write a c program to find largest number in matrix(in each row,each column, diagonally, and in the whole matrix)? Its urgent.

2 Answers  


what are bit fields in c?

0 Answers  


Write the program that calculates and prints the average of several integers. Assume that the last value read is sentinel 9999.

0 Answers  


Is it possible to run a c program without using main?If yes HOW??

13 Answers   Wipro,


Categories