Computer Science, asked by leishapmenezes, 5 months ago

Decision and control structures in Java
(Class 8)

Answer the following
1. What is the purpose of using default case in switch statement?
2. What is an if statement? Write its syntax.
3. Explain the situation where switch statement is used.
4. Give the differences between do-while loop and while loop.
5. Explain the working of the for loop with an appropriate example.

Answers

Answered by rupalibhakat66
8

Answer:

1.A switch statement can have an optional default case, which must appear at the end of the switch. The default case can be used for performing a task when none of the cases is true. No break is needed in the default case.

2.Syntax. The syntax of an 'if' statement in C programming language is − if(boolean_expression) { /* statement(s) will execute if the boolean expression is true */ } If the Boolean expression evaluates to true, then the block of code inside the 'if' statement will be executed.

3.In computer programming languages, a switch statement is a type of selection control mechanism used to allow the value of a variable or expression to change the control flow of program execution via search and map.

4.While loop is executed only when given condition is true.

Whereas, do-while loop is executed for first time irrespective of the condition. After executing while loop for first time, then condition is checked.

5.A loop is used for executing a block of statements repeatedly until a particular condition is satisfied. For example, when you are displaying number from 1 to 100 you may want set the value of a variable to 1 and display it 100 times, increasing its value by 1 on each loop iteration.

Answered by Anonymous
27

Answer:

A piece of advice for all my friends who are reading this: Life brings us as many joyful moments as it does downfalls, and ...

Top answer · 2 votes

Explanation:yup ur right................ More

0 votes

Answer:ya you are rightExplanation:i need a cute gf More

Similar questions