"Z Code Writer" is an Online Blog for Programmer & Beginner. Here, You will Find tech, Build your Programming Skills and other Programming Language Like C, C++, HTML, Java Script Java Code, Web Designing and University Of Sialkot (USKT) CGPA / GPA Calculator etc.

Monday, 22 July 2019

Control Structure

Control Structure

        When a computer program is executed, the execution control moves from one statement to another statement to take actions on program statements. C-language provide features to control; the flow of execution in a program. The statements that are used to control the flow of execution in a program are called control structures.
      There are three kinds of control structures.

  1. Sequence Structure
  2. Selection Structure
  3. Repetition Structure

  • Sequence Structure

      In a sequence structure, the statements of a program are executed in the same order in which they are written in the program. The statements are executed one after the other. All statements of the program are executed. For example, a set of statements is written below.
                           Statement - 1 ;
                           Statement - 2 ;
                                    |
                           Statement - n ;
      All Statement from Statement-1 to Statement-n will be executed in sequence.


  • Selection Structure

      The selection structure is used for selecting a statement or a group of statement for execution on the basis of a given condition. The selection structure is also known as decision structure.
      The instruction of the program are written in a sequence but selection structure are used for making decisions. The given condition is tested. If given condition is true, then statement(s) that follow the selection structure, are executed. Otherwise these are ignored and alternative path is followed.
In C, the most important selection structures are as follows:
  1. The if statement
  2. The if-else statement
  3. The switch statement

  • Repetition Structure

      Repetition structure is used to execute a statement or a set of statements repeatedly as long as the given condition remains true. Repetition structure is also known as iteration structure or loop structure.
      C-language provides the following repetition or loop structures:
  1. while loop
  2. do-while loop
  3. for loop

No comments:

Post a Comment

Thanks For Visiting Here...!! I will Reply you as soon as possible.