# C program to checkperfect number ornotusing pointer

## C program to checkperfectnumber or not using pointer

This page has a C program to check perfect number or not using pointerThe Perfect number must be equal to the sum of all its positive divisors except that number. 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 is used to check a given number is perfect or not using pointer. Kindly check out the program to find whether the given number is perfect number or not using pointer. The same problem for the program can be asked in different ways as 1). Find out the perfect number using C program using pointer.  2). C program to verify whether the given number is perfect or not using pointer 3). C program to find whether the given number is perfect or not using pointer.  4). C Program to check whether number is Perfect or not using pointer.  5). C Program to check whether a number is Perfect or not using pointer. 6). C program to check a given number is perfect number or not using pointer.  7). C Program to find the entered number is perfect number or not using pointer.

### Program to check perfect number using pointer

#include<stdio.h>
int perfect(int *);
int main(){
int n,sum1;
clrscr();
printf("Enter a number as integer : ");
scanf("%d",&n);
sum1= perfect(&n);
if(sum1 == n)
printf("\nThe number %d is a perfect number",n);
else
printf("\nThe number %d is not a perfect number",n);
getch();
return 0;
}

int perfect(int *numbr){
int a=1, sum=0;
while(a < *numbr){
if(*numbr % a == 0)
sum=sum+a;
a++;
}
return(sum);
}

Sample outputs:

Enter a number as integer  :  6

The number 6 is a perfect number

Enter a number as integer  :  28

The number 28 is a perfect number

Enter a number as integer  :  23

The number  23 is not a perfect number

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

The above C program is used to check a given number is perfect or not using pointer. The perfect number will be equal to the sum of all its positive divisors excluding that number. Kindly check out the program to to find a given number is perfect number or not using pointer.