- Hello World c
- C Program to Add Two Numbers
- Area of Triangle C
- Odd or Even C
- Write a C program to find the sum of digitis of a given number
- Write a C program to find the maximum of three numbers
- Write a C program to swap two number using third variable
- Write a C program to swap to numbers without using third variable
- Write a C program to calculate the area of circle
- Write a C program to calculate the Binomial Coefficient (nCr)
- Write a C program to calculate the permutations (nPr)
- Write a C program to reverse the number
- Write a c program to check the given number is palindrome or not
- Write a c program to check the given number prime or not
- Write a c program to check the given number is armstrong or not
- Write a C program to generate all Armstrong number till n
- Write a program to check given number perfect or not
- Write a C program to check alphabet is vowel or consonant
- Write C program to calculates the factorial of a given number
- Write a C program generate and prints the Fibonacci series up to a user-defined limit
- Write a C program to calculate the nth number in the Fibonacci series using recursion
- Write a C program to find the maximum element in the array
- Write a C program to find the minimum element in the array
- Write a C program to search the element using linear search technique
- Write a C program to Insert element in array

A number is called **perfect number**, positive integer number that is equal to the sum of the its possible factor.

For example:

6 is a perfect number or not.

The possible factors of 6 is 1, 2, 3. So these are the possible factors of 6 So now add(sum) these factors 1 + 2 + 3 = 6

6 is a **perfect** number.

```
// check perfect number in c
#include<stdio.h>
int main(){
int n;
printf("Enter the Number : ");
scanf("%d", &n);
int sum = 0;
for(int i=1; i<n; i++){
if(n%i==0){
sum = sum + i;
}
}
if(sum == n){
printf("%d is the Perfect Number",n);
}else{
printf("%d is Not Perfect Number",n);
}
return 0;
}
```

- Initialized a variable n, which stores the value of given by user.
- Initialized a another variable sum. Which stores the sum of factors of given number. Here we initial assigned the value is zero (0).
- Start the for loop, in for loop we initialized a variable i which is initial assigned the value is one (1), this loop is work until the given condition is will be false. Condition is (i < n). When this condition is true then repeat the step 4.
- If (n % i == 0) is true the go to and execute this piece of code (sum = sum + i).
- After complete this process we compare the given value n is and sum if the both are equal then we print given number is
**perfect number**otherwise print given number is**not perfect number**.

1. Start

2. Declared n as integer

3. Read n from the user

4. Set sum = 0

5. Iterate from 1 to n and go to step 6

6. Check n % i == 0 then step 7

7. Set sum = sum + i

[End loop]

8. if sum == n

PRINT "perfect number"

9. else

PRINT "not a perfect number"

10. End

1. INCLUDE stdio.h

2. FUNCTION main()

1. DECLARED n AS INTEGER

2. PRINT "Enter the Number: "

3. READ n FROM USER

4. SET sum = 0

5. FOR i to n - 1

1. IF n % i == 0

SET sum = sum + i

6. IF sum == n

PRINT "perfect number"

7. ELSE

PRINT "not perfect number"

8. RETUTRN 0

ðŸ–¤ 0

Buy me coffee â˜•

## Comments

Oops!