# c program to check perfect number or not

list of programs below: c program to check perfect number or not using functions, c program to check perfect number or not using for loop, c program to check perfect number or not using while loop, c program to find perfect numbers below n, c program to find perfect numbers between 1 and n, c program to find perfect numbers between 1 and 1000

A number is perfect if sum of its factors is equal to same no. example : 6 who factors are 1, 2, 3 and their sum equal to 6.

## Write a c program to find a number is perfect or not using functions

Write a c program to find a number is perfect or not using functions

#include<stdio.h>
void main(){
int n;
printf(“\nEnter a no. \n”);
scanf(“%d\n”,&n);
findpft( n );
}

void findpft( int num)
{
int i, num, sum= 0;
for (i=1;i<num;i++)
{
if(num%i==0)
sum=sum+i;
}
if(sum==num)
printf(“\n %d is perfect “,i);
else
printf(“\n not “);
}

## Write a c program to check  perfect number or not using for loop

Write a c program to check  perfect number or not using for loop

#include<stdio.h>
void main(){
int num,i,s=0;
printf(“\nEnter the no. \n”);
scanf(“%d\n”,&num);
for (i=1;i<num;i++)
{
if(num%i==0)
s=s+i;
}
if(s==num)
printf(“\n Yes “);
else
printf(“\n no );
}
}

## Write a C program to check a number is perfect or not using while loop

Write a C program to find perfect number or not using while loop

#include<stdio.h>
void main(){
int n,i=1,sum=0;
printf(“\nEnter the no. \n”);
scanf(“%d\n”,&n);
while (i<n)
{
if(n%i==0)
s=s+i;
i++;
}
if(s==n)
printf(“\n yes “);
else
printf(“\n no “);
}
}

## Write a c program to find perfect numbers below n

Write a c program to find perfect numbers below n

#include<stdio.h>
void main()
{
int n;
printf(“\nEnter a no. \n”);
scanf(“%d\n”,&n);

findpft( n );
}

void findpft( int n)
{
int i,  sum= 0;
printf(“The perfect numbers below %d are :”, n);
for(int a=1;a<n;a++)
{
for (i=1;i<a;i++)
{
if(a%i==0)
sum=sum+i;
}
if(sum==a)
printf(“\t %d  “, a);
}

## Write a c program to find perfect numbers between 1 and 1000

Write a c program to find perfect numbers between 1 and 1000

#include<stdio.h>
void main()
{
findpft( 1,1000 );
}

void findpft( int n, int m)
{
int i,  sum= 0;
printf(“The perfect numbers below %d are :”, n);
for(int a=n;a<m;a++)
{
for (i=1;i<a;i++)
{
if(a%i==0)
sum=sum+i;
}
if(sum==a)
printf(“\t %d  “, a);
}

## Write a c program to find perfect numbers between two given numbers

Write a c program to find perfect numbers between 1 and 1000

#include<stdio.h>
void main()
{
int n,m;
printf(“\n c program to find perfect numbers  \n”);
printf(“\n Enter  first number  \n”);
scanf(“%d\n”,&n);
printf(“\n Enter  second number  \n”);
scanf(“%d\n”,&m);
if(n>m)
{
int temp=n;
n=m;
m=temp;
}
findpft( n,m);
}

void findpft( int n, int m)
{
int i,  sum= 0;
printf(“The perfect numbers below %d are :”, n);
for(int a=n;a<m;a++)
{
for (i=1;i<a;i++)
{
if(a%i==0)
sum=sum+i;
}
if(sum==a)
printf(“\t %d  “, a);
}