Category: C Programming Tips and Tricks

Looping performance 0

Tip of the week#1: Looping performance

Never use two loops if one loop will suffice. Example: for(i=0; i&lt;5; i++) { /*Do something 1*/ } for(j=0; j&lt;5; j++) { /*Do something 2*/ } In the above example, first and the second “for” loop will execute 5 times each. That is the total of 10 times. The performace of the above code can be optimized by using only one for loop as follows: for(i=0; i<5; i++) { /*Do something 1*/ /*Do something 2*/ } The above loop will be executed only 5 times. Thus the time required for execution is reduced. Note: If the instructions in the loop...

Tip of the Week Series 1

Tip of the Week Series

Hello Readers, Welcome to LearnCOnline.com Thanks a lot to all the readers for overwhelming response. Thanks once again for the wonderful feedback provided by you all. After reviewing the feedback we have planned to start “Tip of the Week” series. This series will provide you with the tips on the C Programming language which will be very much useful for the beginners and the advanced programmers as well. We are looking forward to receive your valuable feedback. Thanks, LearnCOnline Team

FREE C Cheatsheet - Speed Up Your C Programming.

FREE C Cheatsheet - Speed Up Your C Programming.

Download a 7-page free cheat sheet for easy and quick access to C Concepts, Snippets, and Syntax.

Thank you! Check you inbox and access your cheat-sheet