regarding do while loop

I'm using the do-while loop in one of my programs but the thing is that the other codes after the do-while loop won't work. It's like there are no codes beyond the do-while loop. (Though I was able to compile and run the program.) What can I do to fix this? :)

Last edited on
does your while have a "correct" condition.
Check if the 'do' body has any "exit" statements.

Can you please give some part of your code, preferably from your do-while loop till some few lines of code after it.
This part covers the do-while loop 'til a printf()

do
{
n++;
d=1;
t=0;

do
{
if ((n%d)==0)
{
f = (t + d);
t = f;
}
d++;
} while (d<n);
if (n==t)
{
printf("%d\n", n);
c++;
}
} while (c<5);


printf("Output using for loop only:\n");
May I know where is variable n initialized ? After do { n++; <- what is the value before come inside ?
n is initialized just before the start of the do loop, the same goes for c :)

n=1;
c=0;
Last edited on
Could it be that it just loops for a long time because 5th perfect number is so big? Either that, or there is something wrong with the algorithm and it loops infinitely..
Topic archived. No new replies allowed.