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 / 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 |
What is the advantage of using #define to declare a constant?
0 Answers Agilent, ZS Associates,
main() { int i; printf("%d", &i)+1; scanf("%d", i)-1; }
How can I invoke another program (a standalone executable, or an operating system command) from within a c program?
What does a run-time "null pointer assignment" error mean?
What is function pointer and where we will use it
In header files whether functions are declared or defined?
What are the types of pointers in c?
What are unions in c?
What is the acronym for ansi?
Can you mix old-style and new-style function syntax?
write a program to print largest number of each row of a 2D array
20. main() { int i=5; printf("%d%d%d%d%d%d",i++,i--,++i,--i,i); } Answer:??????