Search the Q&A Archives

# i am a beginner of c. now i got a problem on this problem,...

<< Back to: LEARN C/C++ TODAY (A list of resources/tutorials)

 Question by Ekin Submitted on 1/28/2004 Related FAQ: LEARN C/C++ TODAY (A list of resources/tutorials) Rating: Rate this question: N/A Worst Weak OK Good Great i am a beginner of c. now i got a problem on this problem, please help me with this^^ Problem D: Write a program that will find the sum of the proper divisors of a given number n. The proper divisors on n are the numbers less than n that divides it evenly; they do not include n itself. If n is 12 then the sum of its divisors is : 1 + 2 + 3 + 4 + 6 = 16.

 Answer by Manish kumar Submitted on 4/3/2004 Rating: Rate this answer: N/A Worst Weak OK Good Great #include main() { int n,s; printf("enter a no."); scanf("%d",&n); for (i=1;i<=n/2;i++) {   if(n%i==0)         s=s+i; } printf("the divisor sum of %d is %d",n,s); }

 Answer by subhash Submitted on 11/24/2004 Rating: Not yet rated Rate this answer: N/A Worst Weak OK Good Great #include main() { int n,s=0; printf("enter a no."); scanf("%d",&n); for (i=1;i<=n/2;i++) {   if(n%i==0)     s=s+i; }

 Answer by Yogita Daga Submitted on 3/14/2005 Rating: Not yet rated Rate this answer: N/A Worst Weak OK Good Great #include void main() {    int sum=1,i,n;    printf("Enter any number to get the sum of its divisor");    scanf("%d",&n);    for(i=2;i<=n/2;i++)    {       if(n%i==0)          sum=sum+i;    }    printf("Sum of Its divisor are %d",sum); }

Your answer will be published for anyone to see and rate.  Your answer will not be displayed immediately.  If you'd like to get expert points and benefit from positive ratings, please create a new account or login into an existing account below.

 Your name or nickname: If you'd like to create a new account or access your existing account, put in your password here: Your answer:

FAQS.ORG reserves the right to edit your answer as to improve its clarity.  By submitting your answer you authorize FAQS.ORG to publish your answer on the WWW without any restrictions. You agree to hold harmless and indemnify FAQS.ORG against any claims, costs, or damages resulting from publishing your answer.

FAQS.ORG makes no guarantees as to the accuracy of the posts. Each post is the personal opinion of the poster. These posts are not intended to substitute for medical, tax, legal, investment, accounting, or other professional advice. FAQS.ORG does not endorse any opinion or any product or service mentioned mentioned in these posts.

<< Back to: LEARN C/C++ TODAY (A list of resources/tutorials)