aspose file tools*
The moose likes Performance and the fly likes Performance difference between for loop and while loop in c++ Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "Performance difference between for loop and while loop in c++" Watch "Performance difference between for loop and while loop in c++" New topic
Author

Performance difference between for loop and while loop in c++

arun david
Greenhorn

Joined: Apr 29, 2005
Posts: 2
Is there any performance difference between for loop and while loop in c++.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Hi Arun,

Welcome to JavaRanch!

This forum is for asking questions about Java performance issues. Similarly, all the other forums concern Java, not C++ (although the "General Computing" forum might be a place for a question like this.) If you've got more C++ questions, it'd be better to take them somewhere else besides JavaRanch.

Rather than move this thread to General Computing, though, I'll answer it just this once: No, in general, there's no difference. In fact, something like



and something like



will generally compile to identical machine code.


[Jess in Action][AskingGoodQuestions]
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
And to bring this thread on topic, the same is true in Java, isn't it?


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Performance difference between for loop and while loop in c++