C program to find the perfect number using while loop| Perfect number in C |E-studyblog

 In this Article, you will learn  C program to find the perfect number using while loop.


C program to find the perfect number using while loop| Perfect number in C |E-studyblog
C program to find the perfect number using while loop| Perfect number in C |E-studyblog




Perfect number :

Perfect number is  a positive number which is equal to the sum of its proper divisors.

For Example: 6 is a perfect number since it is divisible by 1,2 and 3.

Others Perfect numbers are :28,496 Etc


C program to find the perfect number using while loop:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 /* C program to find the perfect number using while loop */
 
#include <stdio.h> 
int main(){
	int i=1,n,s=0;
	printf("\nEnter an Integer:");
	scanf("%d",&n);

        while(i<n)
	{
		if(n%i==0)
		s=s+i;
		i=i+1;
		
	}

	if(s==n)
	
	printf("%d is a Perfect Number:",n); 
	  
        else 
  
        printf("%d is not the Perfect Number:",n);   
    
        return 0;
}


Output:
C program to find the perfect number using while loop| Perfect number in C |E-studyblog

C program to find the perfect number using while loop| Perfect number in C |E-studyblog










I hope you have read our Article " C Program to find perfect of the number using while loop"and  you have collected lots of information from there.If you like the post,then please comment and share among your friends and family. you can write your opinion about my post in the comment box. 


Thank you!


No comments:

Post a Comment

If you have any queries ,please let us know

C Program to Check whether the number is Even or Odd|how to find odd and even numbers in c programming|E-studyblog

I n this Article, you will learn how to   Check  whether the number is  Even or odd. We have shared the source code of odd and even number i...