C Program for perfect numbers

by Nideesh C on April 18, 2011 · 0 comments

in C Programming




#include<stdio.h>
#include<math.h>
void main()
{
int i ,n, sum = 0;
clrscr();
printf(“nnt ENTER A NUMBER…: “);
scanf(“%d”, &n);
for(i=1; i<n; i++)
if(n%i == 0)
sum = sum + i;
if(sum == n)
printf(“nnt THE NUMBER %d IS A PERFECT NUMBER”, n);
else
printf(“nnt THE NUMBER %d IS NOT A PERFECT NUMBER”, n);
getch();
}

Not Satisfied ? Just search & get the result

Related Posts Plugin for WordPress, Blogger...
Be Sociable, Share!

Related posts:

  1. C Program to find the perfect numbers below a given number.
  2. C Program to find the perfect numbers between a given range
  3. C Program for Armstrong numbers
  4. C Program – Find the sum of secondary diagonal of a Matrix
  5. C Program – Find the sum of primary diagonal of a Matrix

Leave a Comment

Previous post:

Next post: