**MASTER OF COMPUTER APPLICATIONS**

Course Code : MCS-011

Course Title : Problem Solving and Programming

Assignment Number : MCA(1)/011/Assign/13

Assignment 2013

**A C program to find out perfect numbers from 1 and 50**

#include<stdio.h> void main() { int NUM,I,SUM=0; clrscr(); for(NUM=1;NUM<50;NUM++) { for(I=1;I<NUM;I++) { if(NUM%I==0) { SUM=SUM+I; } } if(SUM==NUM) { printf("\n%d IS A PERFECT NUMBER",NUM); } SUM=0; } getch(); }

**CODE : –**

```
#include<stdio.h>
void main()
{
int NUM,i,SUM=0;
printf("\nENTER ANY INTERGER AND FIND IS IT PERFECT NUMBER : ");
scanf("%d",&NUM);
for(i=1;i<NUM;i++)
{
if(NUM%i==0)
{
SUM=SUM+i;
}
}
if(SUM==NUM)
{
printf("\n%d IS A PERFECT NUMBER",NUM);
printf(" SINCE SUM OF DIVISORS IS %d \n",SUM);
}
else
{
printf("\n%d IS NOT A PERFECT NUMBER",NUM);
printf(" SINCE SUM OF DIVISORS IS %d \n",SUM);
}
getch();
}
```

**SCREEN SHOTS :- **