answersLogoWhite

0


Best Answer

for (n=1; n<1000; ++n) {

for (sum=0, k=1; k<=n/2; ++k)

if (n%k==0) sum += k;

if (sum==n) printf ("%d\n", n);

}

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: C program for displaying perfect numbers using nested loop?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Is have nested present past future?

"Have nested" is in the present perfect tense.


Write a program in Java which will print all nested loop between 1 to 500?

Sure! Here's a Java program that will print all the nested loops between 1 to 500: public class NestedLoopExample { public static void main(String[] args) { for (int i = 1; i &lt;= 500; i++) { for (int j = 1; j &lt;= 500; j++) { System.out.println(&quot;i=&quot; + i + &quot;, j=&quot; + j); } } } } This program uses two nested for loops to iterate from 1 to 500. It prints the value of i and j for each iteration of the loops.


How do you write a Program of printing prime numbers between 1 to 100 in 1 statement only?

You really need some nested loops; but some programming languages might allow you to write this as one statement.


Is there any difference between programming structures and having a structured program?

In a structured program, any structure can be nested within another structure.


Why nested comments are not allowed?

/*This program is to calculate /*simple interest */ version 1.0*/ Anything in between /* and */ is considered as comment. Hence in the given example version 1.0 is not considered as part of the comment. So nested comments are not allowed.


What is nested logic?

In Nested Logic a Logic is contained within a Logic. If the Outer Logic is TRUE then the internal Logic is executed. Nested IF, Nested For, Nested While, e.t.c are some examples of Nested Logic in Modern Computer Languages.


How do you do nested strcutres program in c plus plus?

As its name suggests, a nested structure is a structure which contains another within it. Here is an example in which the "nApple" structure is nested withing the "nTree" structure: #includestruct nApple{int stem;int skin;};struct nTree{int leaves;nApple redDelicious;nApple grannySmith;};


When was Nested created?

Nested was created in 1977.


Why not to use nested for loops 3 times?

You never want to use nested loops if you can avoid it. Each additional level of loop you add increases the work done by your program exponentially. There are certain cases where this is unavoidable, of course. For example, iterating over objects in 2D or 3D space can require many levels of nested loops.


What is the difference between local class and nested class?

The main difference between a local class and a nested class is, local class can be used for once of a perticular part where as nested class can be used used anywhere through out the program. You may get clear information regarding Interview Questions at http://www.bigvacancies.com/java-interview-questions/


What are examples of nested solids?

three examples of nested solids


What is the if statement that appears inside another if statement?

nested if Statement