×

10th Class Computer Chapter 03 – Conditional Logic

10th Class Computer Chapter 03 – Conditional Logic

Q.1. What is Control statement? Describe Sequential and Selection Statement.

Ans: The Statement used to control the flow of execution of program is called Control Statement.

There are three types of control statements in C language

  1. Sequential Control Statement
  2. Selection Control Statement
  3. Repetition Control Statement

Sequential Control Statement:

Sequential control is the default control structure in C Language. According to the sequential control, all the statements are executes in the given sequence.

 Selection Control Statement:

It help us to decide which statement should be executed next, on the basis of conditions.

Selection Control Statement:

Selection control statement help us to decide which statement should be executed next, on the basis of conditions.

Q. No.2 Explain Different Types of Selection Statement.

There are two types of Selection control statements.

  1. If Statement
  2. If-ElseStatement

IF Statement: C Language provides if statement in which we specify a condition and associate a code to it. Code run If the condition is true, otherwise code does not get execute.

Structure of if statement:

If statement has following structure us C language:

If (Condition)

{

                        Associated Code

}

IF-else Statement: This statement executes the set of statement under if statement. Same as if, if the condition is true if condition executes. Similarly else statements executes if the condition is false.

General structure of if-else statement:

If (condition)

            Associated code

Else

            Associated code.

Associated code of if-statement is executes if the condition is true, otherwise the code associated with else statement is executed.

Note: an if-statement may not have an associated else statement, but an else statement must have an if statement to which it is associated.

Q.3. Explain Nested Selection Control Structure.

Ans: A selection statement within Selection statement is called nested Selection Structure. It means that inside an if block or inside an else block, we can have another if statement or if-else statement.

Some valid nested selection structure are following:

If(condition-1 is true) {             if(condition-2 is true)                         Associated Code } else {             if(condition-3 is true)                         Associated Code }If(condition-1 is true) {             if(condition-2 is true)                         Associated Code             else                         Associated Code }