2dix-The Student Choice
Log in Register now

Write a program of PERFECT NUMBER.

C++ program to show the PERFECT NUMBER.

#include<iostream.h>
#include<conio.h>

void main()
{
int n,i=1,sum=0;
clrscr();
printf("\nEnter a number:-");
scanf("%d",&n);
while(i<n)
{
if(n%i==0)
sum=sum+i;
i++;
}
if(sum==n)
printf("\nThe no %d is a perfect number",i);
else
printf("\nThe no %d is not a perfect number",i);
getch();
}

comments (0)

avatar