Computer Science, asked by RiyaWani, 1 year ago

write a program to check whether it's a perfect no

Answers

Answered by WowSonuPrasad1
4
/*

 * C Program to Check whether a given Number is Perfect Number

 */

#include <stdio.h>

 

int main()

{

int number, rem, sum = 0, i;

 

printf("Enter a Number\n");

scanf("%d", &number);

for (i = 1; i <= (number - 1); i++)

{

rem = number % i;

if (rem == 0)

{

sum = sum + i;

}

}

if (sum == number)

printf("Entered Number is perfect number");

else

printf("Entered Number is not a perfect number");

return 0;

}

Output: $ cc pgm42.c $ a.out Enter a Number 6 Entered Number is perfect number   $ a.out Enter a Number 100 Entered Number is not a perfect number


RiyaWani: it is a positive integer that is equal to the sum of it's proper divisors
Answered by NupurPatel12
5
hope it helps u.........
Attachments:
Similar questions