Search This Blog

Tuesday, 10 October 2017

Checking whether no is perfect or not : C Program

/* checking whether no is perfect or not */ 

#include<stdio.h>
#include<conio.h>

void main()
{
 int no,sum=0,i;
 clrscr();
 printf("Enter no : ");
 scanf("%d",&no);
 for(i=1;i<no;i++)
 {
  if(no%i==0)
  {
   sum=sum+i;
  }
 }
 if(sum==no)
  printf("\n %d is perfect number",no);
 else
  printf("\n %d is Not perfect number",no);
 getch();
}

Output :


No comments:

Post a Comment