1 / 9

LOOPING

LOOPING. Statements in C Programming. P.Suman Dept.of Computer Science Avanthi Degree & P.G College. Introduction. C programming language, there are circumstances where you want to do the same thing many times. For example you want to print the same words ten times.

juana
Télécharger la présentation

LOOPING

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. LOOPING Statements in C Programming P.Suman Dept.of Computer Science Avanthi Degree & P.G College

  2. Introduction C programming language, there are circumstances where you want to do the same thing many times For example you want to print the same words ten times. You could type ten printf function, 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

  3. What is a LOOP? A loop is defined as a block of statements, which are repeatedly executed for a certain number of times Looping statements are used for running a set of statements for any number of times Looping statements are also called as iterative statements

  4. Types of LOOPs? In C Programming there are mainly two types of loops Unbounded loop Bounded loop Note These are also called indefiniteand definite loops respectively

  5. Types of LOOPs? while statement Unbounded loop do - while statement Bounded loop for statement

  6. Unbounded loop Unbounded looping statements are used when we don’t know how many times the set of statements has to be repeat Unbounded looping statements can either be a Pre – Test Loop or be a Post – Test Loop In Pre – Test Loop, condition is checked before the beginning of each iteration. If condition is TRUE repetition is performed, if it is FALSE repetition is not performed

  7. Pre – Test loop is implemented using ‘while’ statement In Post – Test Loop, first the block of statements to be repeat is executed then condition will be tested That means in Post – Test Loop, condition is checked after executing the repeating statements, if the condition is TRUE it repeat the statements again, if it is FALSE repetition is not performed Post – Test loop is implemented using ‘do - while’ statement

  8. While statement counter initialization; while(condition) { block of statements; ….. counter modification; ….. } Syntax

  9. Example #include<stdio.h> void main() { int i=1; while(i <= 10) { printf(“MRIT\n”); i++; } printf(“END”); } inti = 1 F i<=10 T printf….MRIT i++ printf….END

More Related