Skip to main content

Posts

Showing posts with the label Control Statements in C

Control Statements in C

Control statements enable us to specify the flow of program control; ie, the order in which the instructions in a program must be executed. They make it possible to make decisions, to perform tasks repeatedly or to jump from one section of code to another. There are four types of control statements in C:  1.Decision making statements 2.Selection statements 3.Iteration statements 4.Jump statements  1.Decision Making Statement: the if-else Statement The if-else statement is used to carry out a logical test and then take one of two possible actions depending on the outcome of the test (ie, whether the outcome is true or false).  Syntax: if (condition) { statements } else { statements }  If the condition specified in the if statement evaluates to true, the statements inside the if-block are executed and then the control gets transferred to the statement immediately after the if-block. Even if the condition is false and no else-block is present, control gets transferred to t