C++ Program to find Perfect Number using loop

By | 25.12.2016

Perfect Number using loop

Write a C++ Program to find Perfect Number using loop. Here’s simple C++ Program to find Perfect Number using loop in C++ Programming Language.

Numbers in C++

Normally, when we work with Numbers, we use primitive data types such as int, short, long, float and double, etc. The number data types, their possible values and number ranges have been explained while discussing C++ Data Types.

Perfect number : :

A perfect numbers is a positive number that equals the sum of its divisors, excluding itself. This is also known as its aliquot sum. At this time, it is unknown how many perfect numbers truly exist in our number system.

While we have discovered 48 perfect numbers, the fact that there are an infinite number of prime numbers leads us to believe that there could be an infinite number of perfect numbers.

Here is source code of the C++ Program to find Perfect Number using loop. The C++ program is successfully compiled and run(on Codeblocks) on a Windows system. The program output is also shown in below.


/* C++ Program to find Perfect Number using loop */

using namespace std;

int main()                 //Start of main
   int i=1, u=1, sum=0;
 {                                  // start of first loop.

   {                               //start of second loop.
      if(i%u==0 )
     }                          //End of if statement

   }                           //End of second loop

    cout<<i<<" is a perfect number."<<"\n";

   u=1;  sum=0;
 }                             //End of First loop
   return 0;
 }                            //End of main


**************** OUTPUT *****************

6 is a perfect number.

28 is a perfect number.

496 is a perfect number.

Above is the source code for C++ Program to find Perfect Number using loop which is successfully compiled and run on Windows System.The Output of the program is shown above .

If you found any error or any queries related to the above program or any questions or reviews , you wanna to ask from us ,you may Contact Us through our contact Page or you can also comment below in the comment section.We will try our best to reach up to you in short interval.

Thanks for reading the post….

0 0 vote
Article Rating
Notify of
1 Comment
Newest Most Voted
Inline Feedbacks
View all comments
conrad ainebyona

i want to grade any number of students offering any number of subjects , which variables do i use