Introduction to Selection Structure

Default Image

In sequential structure of execution
statements of a program execute one after one. Not a single statement of
program skipped during execution. In some cases, we require to check
condition and skip single or bunch of statements. This process of
skipping statements can be done with the help of control structure.
Control structure not only support skipping the statements but also
support repeating of statements. Control structure have three types that
commonly used are as follows:

  • Sequence structure
  • Selection structure
  • Repetition structure

  • Sequence structure

In this type of structure not a single
statement got skipped during execution of statements. All statements got
executed of program. It means neither a statement skipped or repeated
during execution.


  • Selection structure

In this type of structure every statement
of program didn’t execute. We make some conditions to select weather a
statement is going to execute or not. For making such decision we use
keywords if and else. It helps the programmer in a way that if condition
is true then execute this single statement or bunch of statements else
other statement or bunch of statements execute.


  • Repetition structure

This type of structure used in program
when a user or programmer required to repeat some statements in program.
A statement or set of statements got repeated until the given condition
got true or false. create a structure that help us to repeat
statement/s we use the key word of while, do while and for. To use while
keyword we write program in a way while (condition) and a statement or
bunch of statements, to use do while structure it will be written as do
then set of statements then while (condition). General structure of last
keyword is as for(condition) and set of statements. Main difference
between while and for will be discussed in next.

Read Count: 3 times

Comments

No comments yet.

Leave a Comment