#include<stdio.h>
int main()
 {

     int n,i,c=0;
     printf("\nEnter a no:");
     scanf("%d",&n);
     for(i=1;i<n;i++)
      {
          if(n%i==0)
           {
               c=c+i;
           }

      }

   if(n==c)
     printf("\nPerfect no.");
    else
      printf("\nNot a perfect no.");

 }

Recommended Answers

All 5 Replies

please specify what is the problem in the code .its running well.or your loop is not working properly?

#include<stdio.h>
    #include<conio.h>
    int main()
    {
     
    int n,i,c=0;
    printf("\nEnter a no:");
    scanf("%d",&n);
    for(i=1;i<n;i++)
    {
    if(n%i==0)
    {
    c=c+i;
    }
     
    }
     
    if(n==c)
      {printf("\nPerfect no.");getch();}
    else
      {printf("\nNot a perfect no.");getch();}
     
    }

And more terrible code... Please stop posting just to boost your ego.

hey buddy if u r not aware of c programming language then pl dont visit this site...!!!

First learn c nd then dare to post on ma uploads....!!!

Go learn first champ...!!!

compzets:-
We are not here to check full codes if you are not specifying your problems.what do you want..??
positing the same code doesn't make a clear idea to us again about your problem.

SPECIFY YOUR AREA OF PROBLEM

hey buddy if u r not aware of c programming language then pl dont visit this site...!!!

you should check about the detail of person whom you used to say like this. seems to be you are a newbie.

First learn c nd then dare to post on ma uploads....!!!

you don't ve much idea about the basics of C..google the standards of C and first learn them.

Go learn first champ...!!!

yep you are right...go learn first champ...!!

now to your programming part..

#include<conio.h>

not a recognized file or directory in gcc compliers..

please stop using getch() it's not in use for any gcc compilers.
its terrible to use getch() now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.