Posts

Showing posts from July, 2017

While Loop in C Programming & Examples

1].while Loop The simplest looping structure in C language is while loop. It is Entry Controlled loop statement. Syntax:- Loop Variable=Value; while (condition) { Statement 1; . . . . . . . . . . . . . . . . . . Statement N; Loop Variable Update } 1.       The condition returns boolean value either true or false. If the given condition return true then the body of loop is execute. After the execution of loop body it again tests the given condition and if it is true it again execute the body of loop. This process repeat until the condition remains true. 2.       When the condition returns false, the control is transferred from out of the loop. The program will continue with the statements which are after the while loop. 3.       The body of loop contains one or more statements. The braces are required only if the body contains the two or more statements. ...

Type of Loop in C Programminig

Type of Loop We can classify the loop into two categories. They are: 1].     Pre-Tested Loop : When the control statement is placed at the beginning/top of the loop body is called Pre-Tested or Entry Controlled loop . These types of loop first check the given condition then execute the body of a loop.     Counter=Start Value Loop (condition) {             Statement 1 . . . . . . . . . Statement N Counter Update } Example: - for loop, while loop             2].     Post-Tested Loop : When the control statement is placed at the end/bottom of the loop body is called Post-Tested or Exit Controlled loop . This type of loop first executes the body of a loop then check the given condition. Counter=Start Value Loop {              ...

Loop Statement:-An Introduction

The sequence or selection construct execute a statement or set of statement only one time during the execution of a program while the iterative construct is used to evaluate a statement or set of statement more then one time during the execution of a program. They are also known as repetitive or loop construct. The loop /Iterative construct executed in the following manner: i). The execution of loop is start with the help of a variable (counter) which contains the start value from where the counting is to be started. The value of counter variable must be updated with each step/ iteration of the loop. iii). The loop is controlled on the basis of a condition which usually compares the counter variable with the specified end value. The condition returns a Boolean value true or false. iii). If the condition returns true the statements enclosed within the body of loop are executed continuously. If the given condition is false it skips the statements enclosed within the body of ...

Introduction to If Else Statement

Decision Construct: - An Introduction They provide the facility to specify the certain condition in a program and associate a set of statements with that condition. These conditions are evaluated during the execution of program. These conditions must return a Boolean value true or false. The associated group of statements is executed if the given condition is true. If the given condition is false it skips the associated group of statements and executes the remaining statements of a program. C language provides three Decision constructs. They are: i]. If Statement                                     ii]. Switch…case Statement                            ...