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 |
WHOT IS CHAR?
What does a derived class inherit from a base class a) Only the Public members of the base class b) Only the Protected members of the base class c) Both the Public and the Protected members of the base class d) .c file
Write a C program to fill a rectangle using window scrolling
Write a pro-gramme to determine whether the number is even or odd?
What is calloc malloc realloc in c?
What are high level languages like C and FORTRAN also known as?
write a program to find the given number is prime or not
2 Answers Accenture, Vasutech,
I completed my B.tech (IT). Actually I want to develop virtual object that which will change software technology in the future. To develop virtual object what course I have to take. can I any professor to help me.
Why can't I perform arithmetic on a void* pointer?
How are pointers declared in c?
how i m write c program 1.check prime number 2.prime number series
Write a program that takes three variables(a,b,c) in as separate parameters and rotates the values stored so that value a goes to b,b,to c and c to a