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 null in c?

0 Answers  


how to write a cprogram yo get output in the form * *** ***** ******* ********* ******* ***** *** *

3 Answers  


What are the main characteristics of c language describe the structure of ac program?

0 Answers  


2.Given the short c program that follows a. make a list of the memory variables in this program b.which lines of code contain operations that change the contents of memory? what are those operations? Void main( void) { Double base; Double height; Double area; Printf(“enter base and height of triangle :”); Scanf(“%lg”, &base); Scanf(“%lg”, &height); Area=base*height/2.0; Printf(“the area of the triangle is %g \n”,area); }

1 Answers   Wipro,


Difference between MAC vs. IP Addressing

0 Answers  






Mention four important string handling functions in c languages .

0 Answers  


how would a 4*3 array A[4][3] stored in Row Major Order?

0 Answers   HCL, Ignou,


What is indirection?

0 Answers  


p*=(++q)++*--p when p=q=1 while(q<=6)

0 Answers   KINPOE,


Explain what will the preprocessor do for a program?

0 Answers  


main() { int x=2, y=4 if ((x==2||y==4) x++ y++ if (y==4+1) { x=x+y; } y++; printf("The values of x and y are %d and %d."x,y); } What is the output?

5 Answers   TCS,


What do you mean by dynamic memory allocation in c?

0 Answers  


Categories