[go: up one dir, main page]

0% found this document useful (0 votes)
68 views4 pages

CHAPTER 11 Computer Class 12

This document contains questions and answers about control structures and decision constructs in C programming. It defines control structures and lists their main types as sequential, selection, and iteration. It describes simple if statements and if-else statements, provides their syntax, and draws a flowchart for if-else. It also compares nested if statements to sequences of if statements, explains the use of the break statement in switch structures, why default labels are used in switch statements, and defines conditional operators.

Uploaded by

shaheeneditx97
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views4 pages

CHAPTER 11 Computer Class 12

This document contains questions and answers about control structures and decision constructs in C programming. It defines control structures and lists their main types as sequential, selection, and iteration. It describes simple if statements and if-else statements, provides their syntax, and draws a flowchart for if-else. It also compares nested if statements to sequences of if statements, explains the use of the break statement in switch structures, why default labels are used in switch statements, and defines conditional operators.

Uploaded by

shaheeneditx97
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Chapter: 11 Decision Constructs

Questions Provided by: Sir Mateen Prepared By: Hussain Mehdi

Short
Questions
Q: 1 Define control structure. Write its types.
Answer: Control structures are statements used to control the execution flow in a
program or function. The C control structure enables us to group individual
instructions into a single logical unit with one entry point and one exit point.

Types:
The following are the different types of control structures:
 Sequential control structure.
 Selection control structure.
 Iteration control structure.
Q: 2 What is a simple if statement? Write its syntax.
Answer: If statement is the simplest form of decision construct. It allows a
statement or a set of statements to be executed conditionally. The general form
of a simple if statement is:
if (condition)
{
Statement1;
Statement2;
Statement (n);
}
Q: 3 Draw the flow chart if-else statement.
Answer:

F T
Condition

Statement Statement

Q: 4 what is an if-else statement? Write its syntax.


Answer: The statement that is used to implement the condition is either true (1)
or false (0).
Syntax:
if (condition)
{
True-Case;
}
Else
{
False-Case:
}
Q: 5 Compare nested if and sequence of if.
Answer: It is due to the complexity of nested if statements that beginners usually
prefer to use a sequence of if statements rather than a single nested if statement.
However, sometimes it is useful to use a nested if instead of a sequence of ifs. In
the case of a nested if statement, when the control flow reaches a logical
decision, the rest of the conditions are skipped. Whereas in a sequence of if
statements, all conditions are tested in any case.
Q: 6 write the use of break statement in switch structure in c.
Answer: You can use the break statement to end the processing of a particular
labeled statement within the switch statement. It branches to the end of the
switch statement. Without a break, the program continues to the next labeled
statement, executing the statements until a break or the end of the statement is
reached.
Q: 7 Why do we use the default label in the switch statement in c?
Answer: The default statement is executed if no case constant-expression value is
equal to the value of the expression. If there's no default statement, and no case
match is found, none of the statements in the switch body get executed.
Q: 8 What are conditional operators?
Answer: Conditional operators are the alternative to the if-else statement.
Conditional operators test the expression and show the result true or false. The
conditional operator is a ternary operator ( uses three operands). The expressions
used in conditional operators are relational or logical.

Syntax:
Conditional expression? true-case statement: false-case statement;

You might also like