Executing statements repeatedly with loops

- In this video we are going to learn a new…structured command sequence in C called loops.…Loops are very useful when we need to repeat…a block of code more than once.…For example, on different data sets,…same data set but with different parameters,…or we need to repeat execution…until some condition is met.…Can you think of an additional instance?…Let's examine one such construct in C…called the For loop.…

There are many types of loops in C,…this is just one of them.…The For loop is very helpful when you know…a precise number of time a set of commands…or function calls must be executed.…The syntax for For is quite simple.…You have to give it three parameters.…One is a start value, the max value,…when to stop, and the increment.…For example, if you would like to execute…something 10 times, the start value could be one,…the max value could be 11,…and the increment would be one.…

Then the k, which is the counter in the loop,…will perform this from one to 10.…The way this works is k is initially assigned…a start value, for example, one, it checks…

Resume Transcript Auto-Scroll

Author

Released

6/30/2014

Widely used for both systems and application development, C is a powerful language at the heart of many more modern languages, like JavaScript and Objective-C. In this course, professor Isac Artzi dissects the anatomy of C, from data types, strings, and variables to simple functions. He'll show how these basic elements fit together in control structures like loops and if-else statements—where the real logic behind your code comes into play. Plus, learn how C organizes information into arrays and how you can manage memory resources with pointers.

C is a great first step for new programmers, and a way to broaden and deepen your knowledge if you've already programmed for a while. Press Play to start learning.