C program to find  the perfect numbers between a range

C program to find the perfect numbers between a given range

Perfect number is an Integer number. The Perfect number is equal to the sum of all its positive divisors excluding the number itself. For example: 6 is a Perfect number ( that is, 1 + 2 + 3 = 6 ), 24 is a Perfect number ( that is, 1 + 2 + 4 + 7 + 14 = 28 ) The below given C program to find the perfect numbers between a given range. Kindly check out the program to find the perfect numbers between a range.


Program to find  the perfect numbers between range


  #include<stdio.h>
  int main(){
                   int sum=0,p,i;
                   int initial,final;
                   printf("\n Enter the initial range: ");
                   scanf("%d",&initial);
                   printf("\n Enter the final range: ");
                   scanf("%d",&final);
                   printf("\n Perfect numbers between the given range are: ");
                   for(i= initial; i<= final; i++){
                   p=1;
                   while(p<=(i/2)){
                   if(i % p == 0)
                   sum=sum+p;
                   p++;
                   }
                   if(sum==i)
                   printf(" %d ",i);
                   sum=0;
                   }
                   return 0;
                   }

 


Sample output:

     Enter the initial range:   1

     Enter the final range:   20

     Perfect numbers between the given range are    6

 


Most Related Perfect or not Programs in C


*c program to check whether a number is perfect number or not.

* C program to display Perfect numbers between given range.

* C program to display the Perfect numbers between 1 and 100.

*C program to check a number is perfect number or not using function

*C program to check a number is perfect number or not using pointer 

Other Related C Programs :


* C Program to find whether the given number is Odd or Even

* C Program to find the Sum of Odd Digits

* C Program to find the Sum of Even Digits

* C Program to find the Sum of Even and Odd Digits,

* C Program to Display Odd digits

* C Program to Display even digits

* C Program to Display Odd Numbers,

* C Program to Display Even Numbers,

* C Program to Check whether the given number is Armstrong number

* C Program to display the Armstrong numbers in Range

* C Program to display the Armstrong numbers between 1 and 1000

* C Program to check perfect number, perfect numbers in range

* C Program to Check Prime number, Prime numbers between 1 and 100

* C Program to display the Prime numbers in a Range

* C Program to display the Sum of Prime numbers

* C Program to Check Strong number

* C Program to display the Strong number in Range

* C Program to Check whether the given number is polindrome number or not

* C Program to Check polindrome number using for loop

* C Program to Check polindrome number using Recursion

* C Program to  check whether the given string is polindrome or not

* C Program to find the Roots of Quadratic equation

* C Program to display Fibonacci Series

* C Program to display the Fibonacci Series using an array

* C Program to display the Fibonacci Series using while loop

* C Program to find the Sum of Fibonacci Series, Factorial of Number

* C Program to find the Factorial without using Recursion

* C Program to find the Factorial using Pointers

* C Program to find the Factorial using Function

Bookmark and Share