diff --git a/programs/C/perf.c b/programs/C/perf.c new file mode 100644 index 0000000..3ce2368 --- /dev/null +++ b/programs/C/perf.c @@ -0,0 +1,26 @@ +#include + +int main() +{ + int sum=0,n; + //prompting user for number to check whether it is perfect or not + printf("please enter number to check whether it is perfect or not"); + scanf("%d",&n); + //finding sum of divisors of entered number + for(int i=1;i<=n/2;i++) + { + if(n%i==0) + { + sum+=i; + } + } + //checking if sum of divisors is equal to entered number or not and then printing required output + if(sum==n) + { + printf("hurray!,entered number is perfect\n"); + } + else + printf("number is not perfect, try another one\n"); + + +}