Re: which loop is better

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jan 28, 2004 at 14:59:51 +0530, Mandeep Singh Sandhu wrote:
> Hi all,
> a small doubt on a loop. If i have to use a loop
> which one is preffered/better - a "for" or a "while"
> loop???
> 
> i had written small prog (2 files)
> 
> file 1 had
> 
> main()
> {
> 	int i=10;
> 	for(;i--;);
> }
> 
> file 2 had
> 
> main()
> {
> 	int i=10;
> 	while(i--);
> }
> 
> both of them produced the SAME assembly code.
> so is there really ne reason why i shud pick one over the other???

You have already answered yourself -- they are exactly equivalent. It's
just a matter of taste.

-------------------------------------------------------------------------------
						 Jan 'Bulb' Hudec <bulb@ucw.cz>

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux