4. Control Statements in C and it's type

4. Control Statements in C and it's type

C provides two types of Control Statements

  • Branching Structure 
  • Looping Structure 

4.1 Branching Structure

Branching is deciding what actions to take and looping is deciding how many times to take a certain action.Decision making structures require that the programmer specifies one or more conditions to be evaluated or tested by the program, along with a statement or statements to be executed if the condition is determined to be true, and optionally, other statements to be executed if the condition is determined to be false. Show below is the general form of a typical decision-making structure found in most of the programming languages.

Figure: Flow Chart Control Statement

Types of Branching Structure:

  • if..else Statement
  • if..else Statement
  • if..else if..else Statement
  • Nested if Statement
  • Switch Statement
  • The ? : Operator

4.2 Looping Structure

Programming languages provide various control structures that allow for more complicated execution paths. A loop statement allows us to execute a statement or group of statements multiple times.C programming language provides the following types of loops to handle looping requirements.
  • while loop
  • do while loop 
  • for loop

No comments:

Post a Comment