0% found this document useful (0 votes)
194 views

Ch-6 Decision Control Structure (Java)

The document discusses different types of control structures in Java including selection and iteration structures. It distinguishes between while and do-while loops, noting that while loops check the condition first before executing the body while do-while loops check after executing the body at least once. It also distinguishes break, which terminates the current loop or switch, from continue which skips to the next iteration of the current loop. The document asks questions to test understanding of these concepts and provides examples of code output.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
194 views

Ch-6 Decision Control Structure (Java)

The document discusses different types of control structures in Java including selection and iteration structures. It distinguishes between while and do-while loops, noting that while loops check the condition first before executing the body while do-while loops check after executing the body at least once. It also distinguishes break, which terminates the current loop or switch, from continue which skips to the next iteration of the current loop. The document asks questions to test understanding of these concepts and provides examples of code output.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

CLASS – VIII

SUBJECT – COMPUTER
CHAPTER – 6 , Decision Control structure

Q4 Distinguish between the following pairs.

a. While and Do..while loop


While Loop Do while loop
It is an Entry controlled loop It is an Exit controlled loop
At first step testing is done first Testing is done at the End of the loop.
Control enters to the body of loop with test Control enters to the body of loop without
the condition and executes the statement test the condition and executes the
only when the condition is true. statement even if the condition is false.

b. Break and continue


Break Continue
This statement terminate(exit) the loop or This statement causes the loop to skip the
switch statement and transfer the execution remainder of its body and immediately retest
to the statement immediately following the its condition prior to reiterating.
loop or switch.

Q5 Very short answer type question:-

a. The three control structure are:-


Sequential Control Structure
Selection Control Structure
Iteration (Looping) Control Structure
b. The statements that Java provides for implementing the selection control structure are:-
If Statement
If-else Statement
If –else-If statement
Switch statement
c. Two Entry controlled loop are:-
For loop
While loop
d. If the condition mentioned with while is not true initially the control will exit the loop without
executing the statements under the body of the loop.

Q6 Long answer type question:-

a. If the condition mentioned with if-else is not true the control will move to else part and execute
the statements inside it without executing the statements inside the IF part.
b. If there will be no curly braces { } after If Condition then by default if statement considers the
immediate one statement to be associated with ‘if’
c. We will enclose the block of statements to be get executed within the curly braces ‘{}’ symbol.
d. In IF – ELSE –IF statement when there are multiple options given from which a decision has to be
made. These statements are executed from the top to down. As soon as one of the conditions
given with ‘If’ is true, the statements associated with ‘If’ are executed, and the rest of the ladder
is bypassed. If none of the conditions is true, then the final ‘else’ statement is executed.

Syntax:- page no. 101

e. In a ‘Switch Statement’ if the value of expression matches with the constant then the control
will move to the matching constant case define within the SWITCH and execute the block of
statements mention under it.
f. Break statement will exit the SWITCH statement by moving the control of execution to the
closing curly braces of SWITCH.
g. The statements which are repeating/executing number of time until the condition becomes
false is called Iteration statement.
h. Only one time
i. Jump statements transfer control to other parts of the program, break and continue are jump
statements in Java like Break, continue.
j. Selection is used for making decisions and branching statements where as Repetition is used for
executing the statements number of times until the condition becomes False.
k. If none of the case mentioned inside the Switch matches with the given constant then the
default case will get executed.

Q7 Write the output

a. Output: 7
8
9
b. Output: 8
c. Output: 7
6
d. Output: 8
9
e. Output: 7
6
5
4
3
2
1
0
-1 (will go infinite) called non terminating loop.

f. Output: 7
9
g. No Output as the condition becomes false. (0>=7)
h. No Output as the condition becomes false. (7<0)
i. No Output as the condition becomes false. (1>=20)
Answer 8: The while loop will get executed only SIX(6) times therefore it have 6 iteration.

Answer 9:-If statement is a decision statement. It is used to decide whether a certain statement or block
of statement will be executed or not. If a certain condition is true, then a statement or block of
statements is executed otherwise not/ move to else part.

Different forms of If statements are:-

If statement
If- Else statement
If-else-If statement
Switch statements

Write the syntax of all the above statements from page no. 98,99,101,103

You might also like