C Program Find Out Perfect Number 6, 28, 496 :
//C Program Find Out Perfect Number 6, 28, 496, 8128
#include<stdio.h>
#include<conio.h>
void main()
{
int num,j,sum=0;
clrscr();
printf("\n Enter a number:- ");
scanf("%d",&num);
for(j=1;j<num;++j)
{
if(num%j==0)
sum=sum+j;
}
if(sum==num)
printf("\n Perfect Number");
else
printf("\n Not perfect number");
getch();
}
OUTPUT#include<stdio.h>
#include<conio.h>
void main()
{
int num,j,sum=0;
clrscr();
printf("\n Enter a number:- ");
scanf("%d",&num);
for(j=1;j<num;++j)
{
if(num%j==0)
sum=sum+j;
}
if(sum==num)
printf("\n Perfect Number");
else
printf("\n Not perfect number");
getch();
}
No comments:
Post a Comment