Skip to main content

Posts

Showing posts with the label control statement

Control Statements: Decisions in C programming

     Since decision making statements control the flow of execution, they also fall under the category of control statements. Following are decision making statements: 1. if statements 2. if....else statements 3. else if statement 4. Nested if...else statement 5. switch statement  if statement: The if statement is a powerful decision making statement and is used to control the flow of execution of statements. This is a bi-directional condition control statements. This statement is used to test a condition and take one of two possible actions, If the condition is true then a single statement or a block of statements is executed (one part of the program), other wise another single statement or a block of statements is executed (other part of the program). In C, any non-zero value is regarded as true while zero is regarded as false. syntax : if (condition) if (condition) statement1 ; { statement1 ; - - - - - statement n ; } Here if the...

Control Statements in C programming

          The statements which alter the flow of execution of the program are called control statements. In the absence of control statements, the instruction or statements are executed in the same order in which they appear in the program. Sometimes, we may want to execute some statements several times. Sometime we want to use a condition for executing only a part of program. So, control statements enable use to specify the order in which various instruction in the program are to be executed. There are two types of control statements : 1. Loops : for, while, do-while 2. Decisions: if, if...else, nested if....else, switch