All the Notes in one Place. Download our Official App from Google Play.

ICS Notes Computer Science Part 2 Chapter 11 Decision Structures of C Short Questions

ICS Notes Computer Science Part 2 Chapter 11 Decision Structures of C Short Questions 2nd Year Notes Online Taleem Ilm Hub

If you want to view other notes of ICS FA Computer Part 2 Please Click Here.



Q 1. What is Control structure?
Ans.  A control structure is a statement used to control flow of execution in a program or function. Control structure is used to combine individual instructions in to a single logical unit. This unit has one entry point and one exit point. Program logic is implemented with the help of control structures. Three kinds of control structures are used to control flow of execution of instructions. These are as follow:

  • Sequence structure
  • Selection structure
  • Repetition structure


Q 2. What is meant by sequence structure?
Ans. In sequence structure the instructions of program executes one after the other in the order in which the are written. It is also called the default flow of a program. The program starts execution from the first instruction and all instructions are executed one by one in a sequence.

Q 3. What is meant by selection structure?
Ans. In selection structure the instructions of the program are divided into two or more groups. Selected group of instructions are executed. This selection is done after evaluation of a certain condition.

Q 4. What is meant by repetition structure?
Ans. Repetition structure is also called iteration structure or loop structure. It is used to execute a statement or set of statement repeatedly as long as the given condition remains true. This control structure is used to repeat same or similar work. There are three basic loop structures in C language. These are as follow:

  • While loop
  • Do-while loop
  • For loop


Q 5. What is IF statement?
Ans. "if" is a keyword in C language. "if" statement is the simplest form of selection structure. It is used to execute or skip a statement or a set of statements after testing a condition. The condition should be a logical or relational expression. After evaluation if the result of condition is true the statement or set of statements after "if" statement executes. If the result of the condition is false the statement or the set of statements after "if" statement are skipped.
The general syntax of if statement is
if(condition)
Statement;

Q 6. What is compound statement?
Ans. A set of statements enclosed in curly brackets is called compound statement. It is also called block of code.

Q 7. What is if-else statement?
Ans. ""if" statement is used to make a decision whether a particular task will be performed or not. If we want to make a two way decision if-else statement is used. After evaluation of condition one from two code blocks will be executed and the other will be skipped. We cannot execute or skip both code blocks.
The general syntax of if-else statement is
if(condition)
Statement;
else
Statement;

Q 8. What is if-else-if statement?
Ans. if-else-if statement is used to execute one compound statement from two of more statements.  If there are more than two compound statement and we want to choose one from them if-else-if statement is used.
The general syntax of if-else-if statement is
if(condition 1)
Statement 1;
else if(condition 2)
Statement 2;
.
.
else if(condition n)
Statement n;.
else
Default statement;

Q 9. What is conditional operator?
Ans. Conditional operator is used as an attribute of simple if-else statement. It is used to make two way decision.
The general syntax of conditional operator is
(Condition)? Statement 1 : Statement 2;

Condition should be a logical or relation expression. After evaluation if the result of condition is true then statement 1 is executed. If result of condition is false then statement 2 is executed.

Q 10. What is switch statement?
Ans. Switch statement is an alternative of if-else-if statement. It is also a conditional statement. It is used when we want to execute a block on statements from multiple blocks.
The general syntax of switch statement is
Switch (expression) {

case constant-expression:
statement (s);
break;
case constant-expression:
statement (s);
break;
default:
statement(s);
}

Q 11. What is nested if statement?
Ans. The use of an "if" statement is used with in another "if" statement is called nested if statement.
The general syntax of nested if statement is
If (Condition 1)
{

If (Condition 2)
{
Statement;
}
}

Q 12. What is break statement?
Ans. Break is a keyword. It is the last statement in each case. It is used to transfer flow of control outside a code block. When break statement executes in switch statement the flow of control is transferred to the first instruction after switch block.

Written by: Asad Hussain

1 Comments

Post a Comment

Previous Post Next Post