+ All Categories
Home > Documents > BY ILTAF MEHDI (MCS, MCSE, CCNA)1. INSTRUCTOR: ILTAF MEHDI (MCS, MCSE, CCNA, Web Developer) BY ILTAF...

BY ILTAF MEHDI (MCS, MCSE, CCNA)1. INSTRUCTOR: ILTAF MEHDI (MCS, MCSE, CCNA, Web Developer) BY ILTAF...

Date post: 18-Jan-2018
Category:
Upload: ruth-berniece-gordon
View: 223 times
Download: 0 times
Share this document with a friend
Description:
BY ILTAF MEHDI (MCS, MCSE, CCNA)3 Course Contents Chapter NoChapter NamePage No 1. The Turbo C Programming Environment C Building Blocks Decisions Loops Functions Arrays and Strings 179

If you can't read please download the document

Transcript

BY ILTAF MEHDI (MCS, MCSE, CCNA)1 INSTRUCTOR: ILTAF MEHDI (MCS, MCSE, CCNA, Web Developer) BY ILTAF MEHDI (MCS, MCSE, CCNA)2 Chapter No: 04 Loops BY ILTAF MEHDI (MCS, MCSE, CCNA)3 Course Contents Chapter NoChapter NamePage No 1. The Turbo C Programming Environment C Building Blocks Decisions Loops Functions Arrays and Strings 179 LOOPS Loops are meant for repeated processing. To execute a set of instructions repeatedly until a particular condition is being satisfied. In every programming language, also in the C programming language, there are circumstances where you want to do the same thing many times. For instance you want to print the same words ten times. You could type ten printf functions, but it is easier to use a loop. The only thing you have to do is to setup a loop that execute the same printf function ten times. Three types of looping statements are there: 1) For Loop 2) While Loop 3) Do while Loop BY ILTAF MEHDI (MCS, MCSE, CCNA)4 The for loop The for loop is frequently used, usually where the loop will be executed to a fixed number of times. OR The for loop works well where the number of iterations of the loop is known before the loop is entered. 5BY ILTAF MEHDI (MCS, MCSE, CCNA) The for loop The head of the loop consists of three parts separated by semicolons. The C for statement has the following form: for (expression 1 ; expression 2 ; expression 3 ) statement; or { block of statements } 1. The first is run before the loop is entered. This is usually the initialization of the loop variable. 2. The second is a test, the loop is exited when this returns false. 3. The third is a statement to be run every time the loop body is completed. This is usually an increment of the loop counter. 6BY ILTAF MEHDI (MCS, MCSE, CCNA) The for loop All the following are legal for-statements in C-language. 1. for (int x=0; ((x>3) && (x3) && (y


Recommended