Click here to Skip to main content
15,793,535 members
Please Sign up or sign in to vote.
3.00/5 (3 votes)
See more:
helloo .
i dont see any erros in this program, My IDE does't execute any program which involve loops.

can anyone suggest me how can i execute this program in

 int j = 2;
for (int i = 1; i < 100; i = i * 2)
    j = j - i;
    while (j < 25)
        j = j + 5;

[edit]Spurious Code block removed - OriginalGriff[/edit]
Updated 12-May-11 10:18am
Smithers-Jones 13-May-11 5:11am    
Please use a descriptive subject line - everybody wants help here.

Loops (even ones as weird as yours) don't take forever to complete. From the looks of it, the outer loop is going to execute 9 times, and at the end, i = 128, and j = 25.

Do what Griff said - run it under the debugger and watch the variables change.
Share this answer
"My IDE does't execute any program which involve loops"
I find that extremely difficult to believe! How do you know that?

Put a breakpoint on the line
int j = 2;
Run your program.
When it gets to the breakpoint, execution will stop.
You can then single step through your program, looking at the variables as you go, and following what happens.
I think you will find that the loops are executed...
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900