write a program to check whether a no is perfect number or not.
Answers
Answered by
0
#include<stdio.h>
#include<conio.h>
void main()
{
int number , rem,sum=0, i ;
clrscr();
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("number is perfect number\n");
else
printf("number is not a perfect number");
getch();
}
#include<conio.h>
void main()
{
int number , rem,sum=0, i ;
clrscr();
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("number is perfect number\n");
else
printf("number is not a perfect number");
getch();
}
Similar questions
Science,
8 months ago
Math,
8 months ago
Physics,
1 year ago
Social Sciences,
1 year ago
Chemistry,
1 year ago