C program to check perfect number or not using pointer

C program to check perfect number 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

 


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 

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.

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