2:10 PM
C++ program to show the 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();
}

Views: 100 | Added by: vijoriya | Tags: Number, Show, c++, Perfect, program | Rating: 0.0/0
Total comments: 0
avatar