68. Number is perfect Yes : Print binary of number No : Print count of factor
#include<stdio.h>
void
main()
{
int r,b,i,num,c=0,sum=0;
printf("Number is perfect \nYes :
Print binary of number \nNo : Print count of factor\n");
printf("Enter a number : ");
scanf("%d",&num);
for(i=1;i<=num;i++)
{
if(num%i==0)
{
sum=sum+i;
c++;
}
}
if(sum-num==num)
{
printf("Its a perfect
number\n");
printf("Binary of %d :
",num);
for(b=31;b>=0;b--)
{
r=num>>b&1;
printf("%d",r);
}
printf("\n");
}
else
printf("Not a perfect
number and factors are %d \n",c);
}
Comments
Post a Comment